stm-containers-0.2.16: Containers for STM

Safe HaskellNone
LanguageHaskell2010

STMContainers.Multimap

Synopsis

Documentation

data Multimap k v Source #

A multimap, based on an STM-specialized hash array mapped trie.

Basically it's just a wrapper API around Map k (Set v).

type Association k v = (Key k, Value v) Source #

A constraint for associations.

type Key k = Key k Source #

A constraint for keys.

type Value v = Element v Source #

A constraint for values.

new :: STM (Multimap k v) Source #

Construct a new multimap.

newIO :: IO (Multimap k v) Source #

Construct a new multimap in IO.

This is useful for creating it on a top-level using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.

insert :: Association k v => v -> k -> Multimap k v -> STM () Source #

Insert an item.

delete :: Association k v => v -> k -> Multimap k v -> STM () Source #

Delete an item by a value and a key.

deleteByKey :: Key k => k -> Multimap k v -> STM () Source #

Delete all values associated with a key.

deleteAll :: Multimap k v -> STM () Source #

Delete all the associations.

lookup :: Association k v => v -> k -> Multimap k v -> STM Bool Source #

Look up an item by a value and a key.

lookupByKey :: Key k => k -> Multimap k v -> STM (Maybe (Set v)) Source #

Look up all values by key.

focus :: Association k v => StrategyM STM () r -> v -> k -> Multimap k v -> STM r Source #

Focus on an item with a strategy by a value and a key.

This function allows to perform simultaneous lookup and modification.

The strategy is over a unit since we already know, which value we're focusing on and it doesn't make sense to replace it, however we still can decide wether to keep or remove it.

null :: Multimap k v -> STM Bool Source #

Check on being empty.

stream :: Multimap k v -> ListT STM (k, v) Source #

Stream associations.

Amongst other features this function provides an interface to folding via the fold function.

streamKeys :: Multimap k v -> ListT STM k Source #

Stream keys.

streamByKey :: Association k v => k -> Multimap k v -> ListT STM v Source #

Stream values by a key.