Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data IMap a
- data Run a = Run {}
- empty :: IMap a
- null :: IMap a -> Bool
- singleton :: Int -> Run a -> IMap a
- insert :: Int -> Run a -> IMap a -> IMap a
- delete :: Int -> Run ignored -> IMap a -> IMap a
- restrict :: Int -> Run ignored -> IMap a -> IMap a
- lookup :: Int -> IMap a -> Maybe a
- splitLE :: Int -> IMap a -> (IMap a, IMap a)
- intersectionWith :: (a -> b -> c) -> IMap a -> IMap b -> IMap c
- mapMaybe :: (a -> Maybe b) -> IMap a -> IMap b
- addToKeys :: Int -> IMap a -> IMap a
- unsafeUnion :: IMap a -> IMap a -> IMap a
- fromList :: [(Int, Run a)] -> IMap a
- unsafeRuns :: IMap a -> IntMap (Run a)
- unsafeToAscList :: IMap a -> [(Int, Run a)]
Documentation
Semantically, IMap
and IntMap
are identical; but IMap
is more
efficient when large sequences of contiguous keys are mapped to the same
value.
Instances
Applicative IMap Source # | Zippy: |
Functor IMap Source # | |
Generic (IMap a) Source # | |
Read a => Read (IMap a) Source # | |
Show a => Show (IMap a) Source # | |
NFData a => NFData (IMap a) Source # | |
Eq a => Eq (IMap a) Source # | |
Ord a => Ord (IMap a) Source # | |
type Rep (IMap a) Source # | |
Run n a
represents n
copies of the value a
.
Instances
Foldable Run Source # | |
Defined in Data.IMap fold :: Monoid m => Run m -> m # foldMap :: Monoid m => (a -> m) -> Run a -> m # foldMap' :: Monoid m => (a -> m) -> Run a -> m # foldr :: (a -> b -> b) -> b -> Run a -> b # foldr' :: (a -> b -> b) -> b -> Run a -> b # foldl :: (b -> a -> b) -> b -> Run a -> b # foldl' :: (b -> a -> b) -> b -> Run a -> b # foldr1 :: (a -> a -> a) -> Run a -> a # foldl1 :: (a -> a -> a) -> Run a -> a # elem :: Eq a => a -> Run a -> Bool # maximum :: Ord a => Run a -> a # | |
Traversable Run Source # | |
Functor Run Source # | |
Generic (Run a) Source # | |
Read a => Read (Run a) Source # | |
Show a => Show (Run a) Source # | |
NFData a => NFData (Run a) Source # | |
Eq a => Eq (Run a) Source # | |
Ord a => Ord (Run a) Source # | |
type Rep (Run a) Source # | |
Defined in Data.IMap type Rep (Run a) = D1 ('MetaData "Run" "Data.IMap" "brick-2.3.1-inplace" 'False) (C1 ('MetaCons "Run" 'PrefixI 'True) (S1 ('MetaSel ('Just "len") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "val") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))) |
restrict :: Int -> Run ignored -> IMap a -> IMap a Source #
Given a range of keys (as specified by a starting key and a length for
consistency with other functions in this module), restrict the map to keys
in that range. restrict k r m
is equivalent to intersectionWith const m
(insert k r empty)
but potentially more efficient.
splitLE :: Int -> IMap a -> (IMap a, IMap a) Source #
splitLE n m
produces a tuple (le, gt)
where le
has all the
associations of m
where the keys are <= n
and gt
has all the
associations of m
where the keys are > n
.
addToKeys :: Int -> IMap a -> IMap a Source #
Increment all keys by the given amount. This is like
mapKeysMonotonic
, but restricted to partially-applied addition.
unsafeUnion :: IMap a -> IMap a -> IMap a Source #
This function is unsafe because it assumes there is no overlap between its
arguments. That is, in the call unsafeUnion a b
, the caller must guarantee
that if lookup k a = Just v
then lookup k b = Nothing
and vice versa.