stm-containers-1.1.0.2: Containers for STM

Safe HaskellNone
LanguageHaskell2010

StmContainers.Multimap

Synopsis

Documentation

data Multimap key value Source #

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

Basically it's just a wrapper API around Map key (Set value).

new :: STM (Multimap key value) Source #

Construct a new multimap.

newIO :: IO (Multimap key value) 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.

null :: Multimap key value -> STM Bool Source #

Check on being empty.

focus :: (Eq key, Hashable key, Eq value, Hashable value) => Focus () STM result -> value -> key -> Multimap key value -> STM result Source #

Focus on an item by the value and the key.

This function allows to perform simultaneous lookup and modification.

The focus 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.

lookup :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM Bool Source #

Look up an item by a value and a key.

lookupByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM (Maybe (Set value)) Source #

Look up all values by key.

insert :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM () Source #

Insert an item.

delete :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM () Source #

Delete an item by a value and a key.

deleteByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM () Source #

Delete all values associated with the key.

reset :: Multimap key value -> STM () Source #

Delete all the associations.

unfoldlM :: Multimap key value -> UnfoldlM STM (key, value) Source #

Stream associations actively.

Amongst other features this function provides an interface to folding.

unfoldMKeys :: Multimap key value -> UnfoldlM STM key Source #

Stream keys actively.

unfoldMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value Source #

Stream values by a key actively.

listT :: Multimap key value -> ListT STM (key, value) Source #

Stream associations passively.

listTKeys :: Multimap key value -> ListT STM key Source #

Stream keys passively.

listTByKey :: (Eq key, Hashable key) => key -> Multimap key value -> ListT STM value Source #

Stream values by a key passively.