stm-containers-0.2.16: Containers for STM

STMContainers.Map

Synopsis

# Documentation

data Map k v Source #

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

type Key a = (Eq a, Hashable a) Source #

A constraint for keys.

new :: STM (Map k v) Source #

Construct a new map.

newIO :: IO (Map k v) Source #

Construct a new map in IO.

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

insert :: Key k => v -> k -> Map k v -> STM () Source #

Insert a value at a key.

delete :: Key k => k -> Map k v -> STM () Source #

Delete an item by a key.

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

Delete all the associations.

lookup :: Key k => k -> Map k v -> STM (Maybe v) Source #

Look up an item.

focus :: Key k => StrategyM STM v r -> k -> Map k v -> STM r Source #

Focus on an item by a key with a strategy.

This function allows to perform composite operations in a single access to a map item. E.g., you can look up an item and delete it at the same time, or update it and return the new value.

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

Check, whether the map is empty.

size :: Map k v -> STM Int Source #

Get the number of elements.

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

Stream associations.

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