Safe Haskell | None |
---|
Implements multi-maps - maps that map keys to sets of values
This module uses the standard naming convention as other collection-like libraries and is meant to be imported qualified.
Synopsis
- newtype MultiMap k v = MultiMap {
- getMultiMap :: Map k (Set v)
- multiMap :: (Ord k, Ord v) => Map k (Set v) -> MultiMap k v
- multiMapL :: (Ord k, Ord v) => k -> Lens' (MultiMap k v) (Set v)
- lookup :: (Ord k, Ord v) => k -> MultiMap k v -> Set v
- member :: (Ord k, Ord v) => k -> MultiMap k v -> Bool
- findValue :: (Ord k, Ord v) => v -> MultiMap k v -> Maybe k
- elem :: (Ord k, Ord v) => v -> MultiMap k v -> Bool
- null :: MultiMap k v -> Bool
- insert :: (Ord k, Ord v) => k -> v -> MultiMap k v -> MultiMap k v
- fromList :: (Ord k, Ord v) => [(k, v)] -> MultiMap k v
- delete :: (Ord k, Ord v) => k -> v -> MultiMap k v -> MultiMap k v
- deleteAll :: (Ord k, Ord v) => k -> MultiMap k v -> MultiMap k v
- values :: (Ord k, Ord v) => MultiMap k v -> Set v
- multiMapValueL :: (Ord k, Ord v) => k -> v -> Lens' (MultiMap k v) Bool
Documentation
A multi-map that contains multiple values for a single key. It doesn't distinguish non-existent keys and keys with the empty set as the value.
MultiMap | |
|
Instances
Foldable (MultiMap k) # | |
Defined in Ganeti.Utils.MultiMap fold :: Monoid m => MultiMap k m -> m foldMap :: Monoid m => (a -> m) -> MultiMap k a -> m foldMap' :: Monoid m => (a -> m) -> MultiMap k a -> m foldr :: (a -> b -> b) -> b -> MultiMap k a -> b foldr' :: (a -> b -> b) -> b -> MultiMap k a -> b foldl :: (b -> a -> b) -> b -> MultiMap k a -> b foldl' :: (b -> a -> b) -> b -> MultiMap k a -> b foldr1 :: (a -> a -> a) -> MultiMap k a -> a foldl1 :: (a -> a -> a) -> MultiMap k a -> a elem :: Eq a => a -> MultiMap k a -> Bool maximum :: Ord a => MultiMap k a -> a minimum :: Ord a => MultiMap k a -> a | |
(Eq k, Eq v) => Eq (MultiMap k v) # | |
(Ord k, Ord v) => Ord (MultiMap k v) # | |
Defined in Ganeti.Utils.MultiMap | |
(Show k, Show v) => Show (MultiMap k v) # | |
(Ord v, Ord k) => Semigroup (MultiMap k v) # | |
(Ord v, Ord k) => Monoid (MultiMap k v) # | |
(JSON k, Ord k, JSON v, Ord v) => JSON (MultiMap k v) # | |
(Arbitrary k, Ord k, Arbitrary v, Ord v) => Arbitrary (MultiMap k v) | |
multiMap :: (Ord k, Ord v) => Map k (Set v) -> MultiMap k v Source #
Creates a multi-map from a map of sets.
multiMapL :: (Ord k, Ord v) => k -> Lens' (MultiMap k v) (Set v) Source #
A Lens
that allows to access a set under a given key in a multi-map.
lookup :: (Ord k, Ord v) => k -> MultiMap k v -> Set v Source #
Return the set corresponding to a given key.
member :: (Ord k, Ord v) => k -> MultiMap k v -> Bool Source #
Tests if the given key has a non-empty set of values.
findValue :: (Ord k, Ord v) => v -> MultiMap k v -> Maybe k Source #
Tries to find a key corresponding to a given value.
elem :: (Ord k, Ord v) => v -> MultiMap k v -> Bool Source #
Returns True
iff a given value is present in a set of some key.
multiMapValueL :: (Ord k, Ord v) => k -> v -> Lens' (MultiMap k v) Bool Source #
A Lens
that allows to access a given value/key pair in a multi-map.
It is similar to the At
instance, but uses more convenient Bool
instead of 'Maybe ()' and a pair key/value.