Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Map k v
- singleton :: (Prim k, PrimUnlifted v) => k -> v -> Map k v
- lookup :: (Prim k, Ord k, PrimUnlifted v) => k -> Map k v -> Maybe v
- size :: PrimUnlifted v => Map k v -> Int
- fromList :: (Prim k, Ord k, PrimUnlifted v) => [(k, v)] -> Map k v
- fromListAppend :: (Prim k, Ord k, PrimUnlifted v, Semigroup v) => [(k, v)] -> Map k v
- fromListN :: (Prim k, Ord k, PrimUnlifted v) => Int -> [(k, v)] -> Map k v
- fromListAppendN :: (Prim k, Ord k, PrimUnlifted v, Semigroup v) => Int -> [(k, v)] -> Map k v
Documentation
A map from keys k
to values v
. The key type and the value
type must both have Prim
instances.
(Prim k, Ord k, PrimUnlifted v) => IsList (Map k v) Source # | |
(Prim k, Eq k, PrimUnlifted v, Eq v) => Eq (Map k v) Source # | |
(Prim k, Ord k, PrimUnlifted v, Ord v) => Ord (Map k v) Source # | |
(Prim k, Show k, PrimUnlifted v, Show v) => Show (Map k v) Source # | |
(Prim k, Ord k, PrimUnlifted v, Semigroup v) => Semigroup (Map k v) Source # | |
(Prim k, Ord k, PrimUnlifted v, Semigroup v) => Monoid (Map k v) Source # | |
type Item (Map k v) Source # | |
singleton :: (Prim k, PrimUnlifted v) => k -> v -> Map k v Source #
O(1) Create a map with a single element.
lookup :: (Prim k, Ord k, PrimUnlifted v) => k -> Map k v -> Maybe v Source #
O(log n) Lookup the value at a key in the map.
List Conversion
fromList :: (Prim k, Ord k, PrimUnlifted v) => [(k, v)] -> Map k v Source #
O(n*log n) Create a map from a list of key-value pairs. If the list contains more than one value for the same key, the last value is retained. If the keys in the argument are in nondescending order, this algorithm runs in O(n) time instead.
fromListAppend :: (Prim k, Ord k, PrimUnlifted v, Semigroup v) => [(k, v)] -> Map k v Source #
:: (Prim k, Ord k, PrimUnlifted v) | |
=> Int | expected size of resulting |
-> [(k, v)] | key-value pairs |
-> Map k v |
O(n*log n) This function has the same behavior as fromList
regardless of whether or not the expected size is accurate. Additionally,
negative sizes are handled correctly. The expected size is used as the
size of the initially allocated buffer when building the Map
. If the
keys in the argument are in nondescending order, this algorithm runs
in O(n) time.