ganeti

Safe HaskellSafe-Infered

Ganeti.Utils.MultiMap

Description

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

Documentation

newtype MultiMap k v Source

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.

Constructors

MultiMap 

Fields

getMultiMap :: Map k (Set v)
 

Instances

Foldable (MultiMap k) 
(Eq k, Eq v) => Eq (MultiMap k v) 
(Ord k, Ord v) => Ord (MultiMap k v) 
(Show k, Show v) => Show (MultiMap k v) 
(Ord v, Ord k) => Monoid (MultiMap k v) 
(Arbitrary k, Ord k, Arbitrary v, Ord v) => Arbitrary (MultiMap k v) 
(JSON k, Ord k, JSON v, Ord v) => JSON (MultiMap k v) 

multiMap :: (Ord k, Ord v) => Map k (Set v) -> MultiMap k vSource

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 vSource

Return the set corresponding to a given key.

member :: (Ord k, Ord v) => k -> MultiMap k v -> BoolSource

Tests if the given key has a non-empty set of values.

findValue :: (Ord k, Ord v) => v -> MultiMap k v -> Maybe kSource

Tries to find a key corresponding to a given value.

elem :: (Ord k, Ord v) => v -> MultiMap k v -> BoolSource

Returns True iff a given value is present in a set of some key.

null :: MultiMap k v -> BoolSource

insert :: (Ord k, Ord v) => k -> v -> MultiMap k v -> MultiMap k vSource

fromList :: (Ord k, Ord v) => [(k, v)] -> MultiMap k vSource

delete :: (Ord k, Ord v) => k -> v -> MultiMap k v -> MultiMap k vSource

deleteAll :: (Ord k, Ord v) => k -> MultiMap k v -> MultiMap k vSource

values :: (Ord k, Ord v) => MultiMap k v -> Set vSource

multiMapValueL :: (Ord k, Ord v) => k -> v -> Lens' (MultiMap k v) BoolSource

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.