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 :: 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 :: 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 # | |
Generic (SegmentMap k a) Source # | |
(NFData a, NFData k) => NFData (SegmentMap k a) Source # | |
type Rep (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 # | |
Generic (OrderedMap k a) Source # | |
(NFData a, NFData k) => NFData (OrderedMap k a) Source # | |
type Rep (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 #
empty :: SegmentMap k a Source #
O(1). The empty segment map.
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 :: 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 |
Monoid k => Measured k (Item k a) Source # | |
Functor (Item k) Source # | |
Foldable (Item k) Source # | |
Traversable (Item k) Source # | |
(Eq a, Eq k) => Eq (Item k a) Source # | |
(Show a, Show k) => Show (Item k a) Source # | |
Generic (Item k a) Source # | |
(NFData a, NFData k) => NFData (Item k a) Source # | |
type Rep (Item k a) Source # | |