Copyright | (c) Arbor Networks 2017 |
---|---|
License | BSD-style |
Maintainer | mayhem@arbor.net |
Stability | experimental |
Portability | non-portable (MPTCs and functional dependencies) |
Safe Haskell | Safe |
Language | Haskell2010 |
Segment maps implemented using the FingerTree
type, following
section 4.8 of
- Ralf Hinze and Ross Paterson, "Finger trees: a simple general-purpose data structure", Journal of Functional Programmaxg 16:2 (2006) pp 197-217. http://staff.city.ac.uk/~ross/papers/FingerTree.html
An amortized running time is given for each operation, with n referring to the size of the map. These bounds hold even in a persistent (shared) setting.
Note: Many of these operations have the same names as similar
operations on lists in the Prelude. The ambiguity may be resolved
using either qualification or the hiding
clause.
- data Segment k = Segment {}
- point :: k -> Segment k
- newtype SegmentMap k a = SegmentMap (OrderedMap (Max k) (Segment k, a))
- newtype OrderedMap k a = OrderedMap (FingerTree k (Item k a))
- delete :: forall k a. (Bounded k, Ord k, Enum k, Eq a, Show k, Show a) => Segment k -> SegmentMap k a -> SegmentMap k a
- empty :: (Ord k, Bounded k) => SegmentMap k a
- fromList :: (Ord v, Enum v, Eq a, Bounded v, Show v, Show a) => [(Segment v, a)] -> SegmentMap v a
- insert :: forall k a. (Bounded k, Ord k, Enum k, Eq a, Show k, Show a) => Segment k -> a -> SegmentMap k a -> SegmentMap k a
- singleton :: (Bounded k, Ord k) => Segment k -> a -> SegmentMap k a
- update :: forall k a. (Ord k, Enum k, Bounded k, Eq a, Show k, Show a) => Segment k -> Maybe a -> SegmentMap k a -> SegmentMap k a
- segmentMapToList :: SegmentMap k a -> [(Segment k, a)]
- data Item k a = Item !k !a
- cappedL :: (Enum k, Ord k, Bounded k, Show k) => k -> FingerTree (Max k) (Item (Max k) (Segment k, a)) -> (FingerTree (Max k) (Item (Max k) (Segment k, a)), FingerTree (Max k) (Item (Max k) (Segment k, a)))
- cappedM :: (Enum k, Ord k, Bounded k, Show k, Show a) => k -> FingerTree (Max k) (Item (Max k) (Segment k, a)) -> FingerTree (Max k) (Item (Max k) (Segment k, a))
Segments
A closed segment. The lower bound should be less than or equal to the higher bound.
Segment maps
newtype SegmentMap k a Source #
SegmentMap (OrderedMap (Max k) (Segment k, a)) |
Functor (SegmentMap k) Source # | |
(Show a, Show k) => Show (SegmentMap k a) Source # | |
newtype OrderedMap k a Source #
Map of closed segments, possibly with duplicates.
The Foldable
and Traversable
instances process the segments in
lexicographical order.
OrderedMap (FingerTree k (Item k a)) |
Functor (OrderedMap k) Source # | |
Foldable (OrderedMap k) Source # | |
Traversable (OrderedMap k) Source # | |
(Show a, Show k) => Show (OrderedMap k a) Source # | |
delete :: forall k a. (Bounded k, Ord k, Enum k, Eq a, Show k, Show a) => Segment k -> SegmentMap k a -> SegmentMap k a Source #
fromList :: (Ord v, Enum v, Eq a, Bounded v, Show v, Show a) => [(Segment v, a)] -> SegmentMap v a Source #
insert :: forall k a. (Bounded k, Ord k, Enum k, Eq a, Show k, Show a) => Segment k -> a -> SegmentMap k a -> SegmentMap k a Source #
singleton :: (Bounded k, Ord k) => Segment k -> a -> SegmentMap k a Source #
O(1). Segment map with a single entry.
update :: forall k a. (Ord k, Enum k, Bounded k, Eq a, Show k, Show a) => Segment k -> Maybe a -> SegmentMap k a -> SegmentMap k a Source #
segmentMapToList :: SegmentMap k a -> [(Segment k, a)] Source #
Item !k !a |