Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A structure mapping unique keys to values
Synopsis
- data Map k a
- empty :: Map k a
- fromList :: Ord k => [(k, a)] -> Map k a
- singleton :: k -> a -> Map k a
- difference :: Ord k => Map k a -> Map k b -> Map k a
- intersection :: Ord k => Map k a -> Map k b -> Map k a
- union :: Ord k => Map k a -> Map k a -> Map k a
- toAscList :: Map k a -> [(k, a)]
- toDescList :: Map k a -> [(k, a)]
- foldlWithKey :: (b -> k -> a -> b) -> b -> Map k a -> b
- foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b
- adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
- delete :: Ord k => k -> Map k a -> Map k a
- filter :: Ord k => (a -> Bool) -> Map k a -> Map k a
- filterWithKey :: Ord k => (k -> a -> Bool) -> Map k a -> Map k a
- insert :: Ord k => k -> a -> Map k a -> Map k a
- update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
- isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
- lookup :: Ord k => k -> Map k a -> Maybe a
- lookupMax :: Map k a -> Maybe a
- lookupMin :: Map k a -> Maybe a
- member :: Ord k => k -> Map k a -> Bool
- null :: Map k a -> Bool
- size :: Map k a -> Int
- traverseWithKey :: Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b)
- valid :: Ord k => Map k a -> Bool
Type
A map from keys k to values a, internally structured as an AVL tree
Instances
Foldable (Map k) Source # | |
Defined in Mini.Data.Map fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldMap' :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # | |
Traversable (Map k) Source # | |
Functor (Map k) Source # | |
Ord k => Monoid (Map k a) Source # | |
Ord k => Semigroup (Map k a) Source # | |
(Show k, Show a) => Show (Map k a) Source # | |
(Eq k, Eq a) => Eq (Map k a) Source # | |
(Ord k, Ord a) => Ord (Map k a) Source # | |
Construction
fromList :: Ord k => [(k, a)] -> Map k a Source #
O(n log n) Make a map from a tail-biased list of (key, value)
pairs
Combination
difference :: Ord k => Map k a -> Map k b -> Map k a Source #
O(n log n) Subtract a map by another via key matching
intersection :: Ord k => Map k a -> Map k b -> Map k a Source #
O(n log n) Intersect a map with another via left-biased key matching
union :: Ord k => Map k a -> Map k a -> Map k a Source #
O(n log n) Unite a map with another via left-biased key matching
Conversion
toAscList :: Map k a -> [(k, a)] Source #
O(n) Turn a map into a list of (key, value)
pairs in ascending order
toDescList :: Map k a -> [(k, a)] Source #
O(n) Turn a map into a list of (key, value)
pairs in descending order
Fold
foldlWithKey :: (b -> k -> a -> b) -> b -> Map k a -> b Source #
O(n) Reduce a map with a left-associative operation and an accumulator
foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b Source #
O(n) Reduce a map with a right-associative operation and an accumulator
Modification
adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a Source #
O(log n) Adjust with an operation the value of a key in a map
filter :: Ord k => (a -> Bool) -> Map k a -> Map k a Source #
O(n) Keep the bins whose values satisfy a predicate
filterWithKey :: Ord k => (k -> a -> Bool) -> Map k a -> Map k a Source #
O(n) Keep the bins whose keys and values satisfy a predicate
insert :: Ord k => k -> a -> Map k a -> Map k a Source #
O(log n) Insert a key and its value into a map, overwriting if present
update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a Source #
O(log n) Modify the value of a key or delete its bin with an operation
Query
isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool Source #
O(n log n) Check whether the bins of one map exist in the other
lookup :: Ord k => k -> Map k a -> Maybe a Source #
O(log n) Fetch the value of a key in a map, or Nothing
if absent
lookupMax :: Map k a -> Maybe a Source #
O(log n) Fetch the maximum value, or Nothing
if the map is empty
lookupMin :: Map k a -> Maybe a Source #
O(log n) Fetch the minimum value, or Nothing
if the map is empty
Traversal
traverseWithKey :: Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b) Source #
O(n) Lift a map with a lifting operation on keys and values