ganeti
Safe HaskellNone

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

Instances

Instances details
Foldable (MultiMap k) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

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

toList :: MultiMap k a -> [a]

null :: MultiMap k a -> Bool

length :: MultiMap k a -> Int

elem :: Eq a => a -> MultiMap k a -> Bool

maximum :: Ord a => MultiMap k a -> a

minimum :: Ord a => MultiMap k a -> a

sum :: Num a => MultiMap k a -> a

product :: Num a => MultiMap k a -> a

(Eq k, Eq v) => Eq (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

(==) :: MultiMap k v -> MultiMap k v -> Bool

(/=) :: MultiMap k v -> MultiMap k v -> Bool

(Ord k, Ord v) => Ord (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

compare :: MultiMap k v -> MultiMap k v -> Ordering

(<) :: MultiMap k v -> MultiMap k v -> Bool

(<=) :: MultiMap k v -> MultiMap k v -> Bool

(>) :: MultiMap k v -> MultiMap k v -> Bool

(>=) :: MultiMap k v -> MultiMap k v -> Bool

max :: MultiMap k v -> MultiMap k v -> MultiMap k v

min :: MultiMap k v -> MultiMap k v -> MultiMap k v

(Show k, Show v) => Show (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

showsPrec :: Int -> MultiMap k v -> ShowS

show :: MultiMap k v -> String

showList :: [MultiMap k v] -> ShowS

(Ord v, Ord k) => Semigroup (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

(<>) :: MultiMap k v -> MultiMap k v -> MultiMap k v

sconcat :: NonEmpty (MultiMap k v) -> MultiMap k v

stimes :: Integral b => b -> MultiMap k v -> MultiMap k v

(Ord v, Ord k) => Monoid (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

mempty :: MultiMap k v

mappend :: MultiMap k v -> MultiMap k v -> MultiMap k v

mconcat :: [MultiMap k v] -> MultiMap k v

(JSON k, Ord k, JSON v, Ord v) => JSON (MultiMap k v) # 
Instance details

Defined in Ganeti.Utils.MultiMap

Methods

readJSON :: JSValue -> Result (MultiMap k v)

showJSON :: MultiMap k v -> JSValue

readJSONs :: JSValue -> Result [MultiMap k v]

showJSONs :: [MultiMap k v] -> JSValue

(Arbitrary k, Ord k, Arbitrary v, Ord v) => Arbitrary (MultiMap k v) 
Instance details

Defined in Test.Ganeti.Utils.MultiMap

Methods

arbitrary :: Gen (MultiMap k v)

shrink :: MultiMap k v -> [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.

null :: MultiMap k v -> Bool Source #

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

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

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

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

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

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.