stm-containers-1.2.0.3: Containers for STM
Safe HaskellSafe-Inferred
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 :: (Hashable key, 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 :: (Hashable key, Hashable value) => value -> key -> Multimap key value -> STM Bool Source #

Look up an item by a value and a key.

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

Look up all values by key.

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

Insert an item.

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

Delete an item by a value and a key.

deleteByKey :: 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.

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

Stream keys actively.

unfoldlMByKey :: 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 :: Hashable key => key -> Multimap key value -> ListT STM value Source #

Stream values by a key passively.