Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data UnorderedIntMap v
- = Empty
- | BitmapIndexed !Bitmap !(SmallArray (UnorderedIntMap v))
- | Leaf !(Leaf v)
- | Full !(SmallArray (UnorderedIntMap v))
- data Leaf v = L !Int v
- empty :: UnorderedIntMap v
- singleton :: Coercible key Int => key -> v -> UnorderedIntMap v
- null :: UnorderedIntMap v -> Bool
- size :: UnorderedIntMap v -> Int
- member :: Coercible key Int => key -> UnorderedIntMap a -> Bool
- lookup :: Coercible key Int => key -> UnorderedIntMap v -> Maybe v
- lookupDefault :: Coercible key Int => v -> key -> UnorderedIntMap v -> v
- (!) :: Coercible key Int => UnorderedIntMap v -> key -> v
- insert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v
- insertWith :: Coercible key Int => (v -> v -> v) -> key -> v -> UnorderedIntMap v -> UnorderedIntMap v
- unsafeInsert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v
- delete :: Coercible key Int => key -> UnorderedIntMap v -> UnorderedIntMap v
- adjust :: Coercible key Int => (v -> v) -> key -> UnorderedIntMap v -> UnorderedIntMap v
- update :: Coercible key Int => (a -> Maybe a) -> key -> UnorderedIntMap a -> UnorderedIntMap a
- alter :: Coercible key Int => (Maybe v -> Maybe v) -> key -> UnorderedIntMap v -> UnorderedIntMap v
- union :: UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v
- unionWith :: forall v. (v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v
- unionWithKey :: Coercible key Int => (key -> v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v
- unions :: [UnorderedIntMap v] -> UnorderedIntMap v
- map :: forall v1 v2. (v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2
- mapWithKey :: Coercible key Int => (key -> v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2
- traverseWithKey :: (Coercible key Int, Applicative f) => (key -> v1 -> f v2) -> UnorderedIntMap v1 -> f (UnorderedIntMap v2)
- difference :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v
- differenceWith :: (v -> w -> Maybe v) -> UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v
- intersection :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v
- intersectionWith :: (v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3
- intersectionWithKey :: Coercible key Int => (key -> v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3
- foldl' :: (a -> v -> a) -> a -> UnorderedIntMap v -> a
- foldlWithKey' :: (a -> Int -> v -> a) -> a -> UnorderedIntMap v -> a
- foldr :: (v -> a -> a) -> a -> UnorderedIntMap v -> a
- foldrWithKey :: (Int -> v -> a -> a) -> a -> UnorderedIntMap v -> a
- mapMaybe :: (v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2
- mapMaybeWithKey :: (Int -> v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2
- filter :: (v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v
- filterWithKey :: forall v. (Int -> v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v
- keys :: UnorderedIntMap v -> [Int]
- elems :: forall v. UnorderedIntMap v -> [v]
- toList :: UnorderedIntMap v -> [(Int, v)]
- fromList :: [(Int, v)] -> UnorderedIntMap v
- fromListWith :: Coercible key Int => (v -> v -> v) -> [(key, v)] -> UnorderedIntMap v
- type Bitmap = Word
- bitmapIndexedOrFull :: Bitmap -> SmallArray (UnorderedIntMap v) -> UnorderedIntMap v
- mask :: Int -> Shift -> Bitmap
- index :: Int -> Shift -> Int
- bitsPerSubkey :: Int
- fullNodeMask :: Bitmap
- sparseIndex :: Bitmap -> Bitmap -> Int
- two :: Shift -> Int -> v -> Int -> v -> ST s (UnorderedIntMap v)
- unionArrayBy :: (a -> a -> a) -> Bitmap -> Bitmap -> SmallArray a -> SmallArray a -> SmallArray a
- update16 :: SmallArray e -> Int -> e -> SmallArray e
- update16M :: SmallArray e -> Int -> e -> ST s (SmallArray e)
- update16With' :: SmallArray e -> Int -> (e -> e) -> SmallArray e
- updateOrConcatWith :: forall v. (v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v)
- updateOrConcatWithKey :: (Int -> v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v)
- filterMapAux :: forall v1 v2. (UnorderedIntMap v1 -> Maybe (UnorderedIntMap v2)) -> UnorderedIntMap v1 -> UnorderedIntMap v2
- equalKeys :: (Int -> Int -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v' -> Bool
Documentation
data UnorderedIntMap v Source #
A map from (possibly newtyped) Int keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
Empty | |
BitmapIndexed !Bitmap !(SmallArray (UnorderedIntMap v)) | |
Leaf !(Leaf v) | |
Full !(SmallArray (UnorderedIntMap v)) |
Functor UnorderedIntMap Source # | |
Foldable UnorderedIntMap Source # | |
Traversable UnorderedIntMap Source # | |
Eq1 UnorderedIntMap Source # | |
Ord1 UnorderedIntMap Source # | |
Read1 UnorderedIntMap Source # | |
Show1 UnorderedIntMap Source # | |
IsList (UnorderedIntMap v) Source # | |
Eq v => Eq (UnorderedIntMap v) Source # | |
Ord v => Ord (UnorderedIntMap v) Source # | The order is total. |
Read e => Read (UnorderedIntMap e) Source # | |
Show v => Show (UnorderedIntMap v) Source # | |
Semigroup (UnorderedIntMap v) Source # | |
Monoid (UnorderedIntMap v) Source # | |
NFData v => NFData (UnorderedIntMap v) Source # | |
type Item (UnorderedIntMap v) Source # | |
A set of values. A set cannot contain duplicate values.
Construction
empty :: UnorderedIntMap v Source #
O(1) Construct an empty map.
singleton :: Coercible key Int => key -> v -> UnorderedIntMap v Source #
O(1) Construct a map with a single element.
Basic interface
size :: UnorderedIntMap v -> Int Source #
O(n) Return the number of key-value mappings in this map.
lookup :: Coercible key Int => key -> UnorderedIntMap v -> Maybe v Source #
O(log n) Return the value to which the specified key is mapped,
or Nothing
if this map contains no mapping for the key.
:: Coercible key Int | |
=> v | Default value to return. |
-> key | |
-> UnorderedIntMap v | |
-> v |
O(log n) Return the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.
(!) :: Coercible key Int => UnorderedIntMap v -> key -> v infixl 9 Source #
O(log n) Return the value to which the specified key is mapped.
Calls error
if this map contains no mapping for the key.
insert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(log n) Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.
insertWith :: Coercible key Int => (v -> v -> v) -> key -> v -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(log n) Associate the value with the key in this map. If this map previously contained a mapping for the key, the old value is replaced by the result of applying the given function to the new and old value. Example:
insertWith f k v map where f new old = new + old
unsafeInsert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v Source #
In-place update version of insert
delete :: Coercible key Int => key -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(log n) Remove the mapping for the specified key from this map if present.
adjust :: Coercible key Int => (v -> v) -> key -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(log n) Adjust the value tied to a given key in this map only if it is present. Otherwise, leave the map alone.
update :: Coercible key Int => (a -> Maybe a) -> key -> UnorderedIntMap a -> UnorderedIntMap a Source #
alter :: Coercible key Int => (Maybe v -> Maybe v) -> key -> UnorderedIntMap v -> UnorderedIntMap v Source #
Combine
Union
union :: UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(n+m) The union of two maps. If a key occurs in both maps, the mapping from the first will be the mapping in the result.
unionWith :: forall v. (v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
unionWithKey :: Coercible key Int => (key -> v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
unions :: [UnorderedIntMap v] -> UnorderedIntMap v Source #
Construct a set containing all elements from a list of sets.
Transformations
map :: forall v1 v2. (v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 Source #
O(n) Transform this map by applying a function to every value.
mapWithKey :: Coercible key Int => (key -> v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 Source #
O(n) Transform this map by applying a function to every value.
traverseWithKey :: (Coercible key Int, Applicative f) => (key -> v1 -> f v2) -> UnorderedIntMap v1 -> f (UnorderedIntMap v2) Source #
O(n) Transform this map by accumulating an Applicative result from every value.
Difference and intersection
difference :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v Source #
O(n*log m) Difference of two maps. Return elements of the first map not existing in the second.
differenceWith :: (v -> w -> Maybe v) -> UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v Source #
intersection :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v Source #
O(n*log m) Intersection of two maps. Return elements of the first map for keys existing in the second.
intersectionWith :: (v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3 Source #
O(n+m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.
intersectionWithKey :: Coercible key Int => (key -> v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3 Source #
O(n+m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.
Folds
foldl' :: (a -> v -> a) -> a -> UnorderedIntMap v -> a Source #
O(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator). Each application of the operator is evaluated before before using the result in the next application. This function is strict in the starting value.
foldlWithKey' :: (a -> Int -> v -> a) -> a -> UnorderedIntMap v -> a Source #
O(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator). Each application of the operator is evaluated before before using the result in the next application. This function is strict in the starting value.
foldr :: (v -> a -> a) -> a -> UnorderedIntMap v -> a Source #
O(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).
foldrWithKey :: (Int -> v -> a -> a) -> a -> UnorderedIntMap v -> a Source #
O(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).
Filter
mapMaybe :: (v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 Source #
O(n) Transform this map by applying a function to every value and retaining only some of them.
mapMaybeWithKey :: (Int -> v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 Source #
O(n) Transform this map by applying a function to every value and retaining only some of them.
filter :: (v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(n) Filter this map by retaining only elements which values satisfy a predicate.
filterWithKey :: forall v. (Int -> v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v Source #
O(n) Filter this map by retaining only elements satisfying a predicate.
Conversions
keys :: UnorderedIntMap v -> [Int] Source #
O(n) Return a list of this map's keys. The list is produced lazily.
elems :: forall v. UnorderedIntMap v -> [v] Source #
O(n) Return a list of this map's values. The list is produced lazily.
Lists
toList :: UnorderedIntMap v -> [(Int, v)] Source #
O(n) Return a list of this map's elements. The list is produced lazily. The order of its elements is unspecified.
fromList :: [(Int, v)] -> UnorderedIntMap v Source #
O(n) Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
fromListWith :: Coercible key Int => (v -> v -> v) -> [(key, v)] -> UnorderedIntMap v Source #
O(n*log n) Construct a map from a list of elements. Uses the provided function to merge duplicate entries.
bitmapIndexedOrFull :: Bitmap -> SmallArray (UnorderedIntMap v) -> UnorderedIntMap v Source #
Create a BitmapIndexed
or Full
node.
index :: Int -> Shift -> Int Source #
Mask out the bitsPerSubkey
bits used for indexing at this level
of the tree.
bitsPerSubkey :: Int Source #
fullNodeMask :: Bitmap Source #
A bitmask with the bitsPerSubkey
least significant bits set.
two :: Shift -> Int -> v -> Int -> v -> ST s (UnorderedIntMap v) Source #
Create a map from two key-value pairs which hashes don't collide.
unionArrayBy :: (a -> a -> a) -> Bitmap -> Bitmap -> SmallArray a -> SmallArray a -> SmallArray a Source #
Strict in the result of f
.
update16 :: SmallArray e -> Int -> e -> SmallArray e Source #
O(n) Update the element at the given position in this array.
update16M :: SmallArray e -> Int -> e -> ST s (SmallArray e) Source #
O(n) Update the element at the given position in this array.
update16With' :: SmallArray e -> Int -> (e -> e) -> SmallArray e Source #
O(n) Update the element at the given position in this array, by applying a function to it.
updateOrConcatWith :: forall v. (v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) Source #
updateOrConcatWithKey :: (Int -> v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) Source #
filterMapAux :: forall v1 v2. (UnorderedIntMap v1 -> Maybe (UnorderedIntMap v2)) -> UnorderedIntMap v1 -> UnorderedIntMap v2 Source #
Common implementation for filterWithKey
and mapMaybeWithKey
,
allowing the former to former to reuse terms.
equalKeys :: (Int -> Int -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v' -> Bool Source #