int-interval-map-0.0.1.0: Interval map
Safe HaskellNone
LanguageHaskell2010

Data.IntervalIntMap

Synopsis

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

Instances details
NFData (IntervalIntMap a) Source # 
Instance details

Defined in Data.IntervalIntMap

Methods

rnf :: IntervalIntMap a -> () #

data Interval Source #

Constructors

Interval !Int !Int 

fromList :: Storable a => [(Interval, a)] -> IntervalIntMap a Source #

Create an IntervalIntMap from a list of (key, value)

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