Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data IntervalIntMap a
- data IntervalIntMapAccumulator s a
- data Interval = Interval !Int !Int
- fromList :: Storable a => [(Interval, a)] -> IntervalIntMap a
- elems :: Storable a => IntervalIntMap a -> [a]
- new :: (PrimMonad m, Storable a) => m (IntervalIntMapAccumulator (PrimState m) a)
- insert :: (PrimMonad m, Storable a) => Interval -> a -> IntervalIntMapAccumulator (PrimState m) a -> m ()
- unsafeFreeze :: (PrimMonad m, Storable a) => IntervalIntMapAccumulator (PrimState m) a -> m (IntervalIntMap a)
- lookup :: Storable a => Int -> IntervalIntMap a -> [a]
- map :: (Storable a, Storable b) => (a -> b) -> IntervalIntMap a -> IntervalIntMap b
- overlaps :: Storable a => Interval -> IntervalIntMap a -> [a]
- overlapsWithKeys :: Storable a => Interval -> IntervalIntMap a -> [(Interval, a)]
Documentation
data IntervalIntMap a Source #
The typical interval map structure models a function of the type f :: Int
- -> Maybe a
. That is, each position in the domain is either annotated by an
- interval or it is not. When you attempt to insert an interval that overlaps
- with an existing one, the new value may either (1) replace or (2) by
- combined with the older one.
-
- This is **not** the model here. The model here is f :: Int -> [a]
! An
- interval map is a bag of intervals which may overlap. When they do overlap
- and you query at a position where multiple ones could be active, you get all
- of them (in some reliable, but unspecified, order; currently insertion
- order, but this is not an API guarantee).
-
- The API uses two objects:
-
- IntervalIntMapAccumulator
: allows insertion. This is a Mutable object and
- insertions should be in a PrimMonad
-
- IntervalIntMap
: allows querying and operations are pure.
-
Instances
NFData (IntervalIntMap a) Source # | |
Defined in Data.IntervalIntMap rnf :: IntervalIntMap a -> () # |
data IntervalIntMapAccumulator s a Source #
fromList :: Storable a => [(Interval, a)] -> IntervalIntMap a Source #
Create an IntervalIntMap
from a list of (key, value)
elems :: Storable a => IntervalIntMap a -> [a] Source #
new :: (PrimMonad m, Storable a) => m (IntervalIntMapAccumulator (PrimState m) a) Source #
New (empty) accumulator
insert :: (PrimMonad m, Storable a) => Interval -> a -> IntervalIntMapAccumulator (PrimState m) a -> m () Source #
Insert a value into an accumulator
unsafeFreeze :: (PrimMonad m, Storable a) => IntervalIntMapAccumulator (PrimState m) a -> m (IntervalIntMap a) Source #
Transform an IntervalIntMapAccumulator
into an IntervalIntMap
. This is
unsafe as the accumulator should **not** be used after this operation is
performed.
lookup :: Storable a => Int -> IntervalIntMap a -> [a] Source #
Lookup all values whose keys intersect the given position
map :: (Storable a, Storable b) => (a -> b) -> IntervalIntMap a -> IntervalIntMap b Source #
Map: note that both the input and output types must be instances of Storable, so this is not a functor.
overlaps :: Storable a => Interval -> IntervalIntMap a -> [a] Source #
Lookup all values that overlap with the given input
overlapsWithKeys :: Storable a => Interval -> IntervalIntMap a -> [(Interval, a)] Source #
Lookup all values that overlap with the given input