hash-cons-0.2.0.0: Opportunistic hash-consing data structure
Safe HaskellNone
LanguageHaskell2010

Data.HashCons.IntMap

Description

This module provides an efficient implementation of maps from Int keys to values. It is a thin wrapper around WordMap, converting Int keys to Word.

Synopsis

Documentation

data IntMap a Source #

empty :: IntMap a Source #

O(1). Create an empty map.

singleton :: Hashable a => Int -> a -> IntMap a Source #

O(1). Create a map with a single key-value pair.

singletonNonEmpty :: Hashable a => Int -> a -> NonEmptyIntMap a Source #

O(1). Create a map with a single key-value pair.

insert :: Hashable a => Int -> a -> IntMap a -> IntMap a Source #

O(log n). Insert a key-value pair into the map.

insertNonEmpty :: Hashable a => Int -> a -> NonEmptyIntMap a -> NonEmptyIntMap a Source #

O(log n). Insert a key-value pair into the map.

lookup :: Int -> IntMap a -> Maybe a Source #

O(log n). Lookup the value at a key in the map.

lookupNonEmpty :: Int -> NonEmptyIntMap a -> Maybe a Source #

O(log n). Lookup the value at a key in the map.

map :: Hashable b => (a -> b) -> IntMap a -> IntMap b Source #

O(n). Map a function over all values in the map.

mapWithKey :: Hashable b => (Int -> a -> b) -> IntMap a -> IntMap b Source #

O(n). Map a function over all key-value pairs in the map.

traverseWithKey :: (Applicative t, Hashable b) => (Int -> a -> t b) -> IntMap a -> t (IntMap b) Source #

O(n). Traverse the map with a function that accesses keys.

union :: Hashable a => IntMap a -> IntMap a -> IntMap a Source #

O(n). The union of two maps. If a key occurs in both maps, the value from the left map is used.

unionNonEmpty :: Hashable a => NonEmptyIntMap a -> IntMap a -> NonEmptyIntMap a Source #

O(n). The union of two maps. If a key occurs in both maps, the value from the left map is used.

intersection :: Hashable a => IntMap a -> IntMap a -> IntMap a Source #

O(n). Intersection of two maps. Only keys present in both maps are included.

intersectionNonEmpty :: Hashable a => NonEmptyIntMap a -> IntMap a -> IntMap a Source #

O(n). Intersection of two maps. Only keys present in both maps are included.

difference :: Hashable a => IntMap a -> IntMap a -> IntMap a Source #

O(n). Difference of two maps. Keys in the first map but not in the second are included.

differenceNonEmpty :: Hashable a => NonEmptyIntMap a -> IntMap a -> IntMap a Source #

O(n). Intersection of two maps. Only keys present in both maps are included.

member :: Int -> IntMap a -> Bool Source #

Check if a key is present in the map.