StmContainers.Multimap

stm-containers-1.2.1: Containers for STM

Safe Haskell | None
Language | Haskell2010

StmContainers.Multimap

Synopsis

- data Multimap key value
- new :: STM (Multimap key value)
- newIO :: IO (Multimap key value)
- null :: Multimap key value -> STM Bool
- focus :: (Hashable key, Hashable value) => Focus () STM result -> value -> key -> Multimap key value -> STM result
- lookup :: (Hashable key, Hashable value) => value -> key -> Multimap key value -> STM Bool
- lookupByKey :: Hashable key => key -> Multimap key value -> STM (Maybe (Set value))
- insert :: (Hashable key, Hashable value) => value -> key -> Multimap key value -> STM ()
- delete :: (Hashable key, Hashable value) => value -> key -> Multimap key value -> STM ()
- deleteByKey :: Hashable key => key -> Multimap key value -> STM ()
- reset :: Multimap key value -> STM ()
- unfoldlM :: Multimap key value -> UnfoldlM STM (key, value)
- unfoldlMKeys :: Multimap key value -> UnfoldlM STM key
- unfoldlMByKey :: Hashable key => key -> Multimap key value -> UnfoldlM STM value
- listT :: Multimap key value -> ListT STM (key, value)
- listTKeys :: Multimap key value -> ListT STM key
- listTByKey :: Hashable key => key -> Multimap key value -> ListT STM value

# Documentation

data Multimap key value #

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) #

Construct a new multimap.

newIO :: IO (Multimap key value) #

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 #

Check on being empty.

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

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 #

Look up an item by a value and a key.

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

Look up all values by key.

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

Insert an item.

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

Delete an item by a value and a key.

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

Delete all values associated with the key.

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

Delete all the associations.

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

Stream associations actively.

Amongst other features this function provides an interface to folding.

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

Stream keys actively.

unfoldlMByKey :: Hashable key => key -> Multimap key value -> UnfoldlM STM value #

Stream values by a key actively.

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

Stream associations passively.

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

Stream keys passively.

listTByKey :: Hashable key => key -> Multimap key value -> ListT STM value #

Stream values by a key passively.