Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

- 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

`Run n a`

represents `n`

copies of the value `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.