|Portability||non-portable (requires STM)|
|Maintainer||Edward Kmett <email@example.com>|
|A simple STM based transactional linear hash table based on Witold 1980.
This wraps a Data.THash.THT in an simple container. It may be
more appropriate to use the underlying THT structure directly if you are
nesting these. The performance hit hasn't yet been measured.
|data THash k v|
|A hash with keys of type k to values of type v
|new :: (k -> Int) -> STM (THash k v)|
|Build an empty hash table
|newH :: Hashable k => STM (THash k v)|
|Build an empty hash table using the default hash function for the key type.
|fromList :: Eq k => (k -> Int) -> [(k, v)] -> STM (THash k v)|
|Build a hash table from a list of (key,value) pairs
|insert :: Eq k => THash k v -> k -> v -> STM Bool|
|Insert a value into the hash table. If a value with the key is present
then nothing is changed and False is returned.
|update :: Eq k => THash k v -> k -> v -> STM ()|
|Insert a value into the hash table, replacing any value with the same key that is present.
|modify :: Eq k => THash k v -> k -> (Maybe v -> v) -> STM ()|
|Update a value in the hash table using the supplied function.
|delete :: Eq k => THash k v -> k -> STM Bool|
|Remove a value from the hash table. Returns True to indicate success.
|lookup :: Eq k => THash k v -> k -> STM (Maybe v)|
|Lookup a value in the hash table.
|mapH :: ((k, v) -> r) -> THash k v -> STM [r]|
|Map a function over all (key,value) functions in the hash table.
|each :: THash k v -> STM [(k, v)]|
|each = mapH id and returns all (key,value) pairs in the hash.
|keys :: THash k v -> STM [k]|
|each = mapH fst and returns all keys in the hash.
|values :: THash k v -> STM [v]|
|each = mapH snd and returns all values present in the hash.
|hashInt :: Int -> Int|
|Thomas Wang's 32 bit mix function; more effective than a prime modulus for
declustering a linear hash, but not good against an adversary, since its easily
|Produced by Haddock version 0.7|