Safe Haskell | None |
---|---|
Language | Haskell98 |
Control.Concurrent.Map
Description
A non-blocking concurrent map from hashable keys to values.
The implementation is based on lock-free concurrent hash tries (aka Ctries) as described by:
- Aleksander Prokopec, Phil Bagwell, Martin Odersky, "Cache-Aware Lock-Free Concurent Hash Tries"
- Aleksander Prokopec, Nathan G. Bronson, Phil Bagwell, Martin Odersky "Concurrent Tries with Efficient Non-Blocking Snapshots"
Operations have a worst-case complexity of O(log n), with a base
equal to the size of the native Word
.
- data Map k v
- empty :: IO (Map k v)
- insert :: (Eq k, Hashable k) => k -> v -> Map k v -> IO Bool
- delete :: (Eq k, Hashable k) => k -> Map k v -> IO Bool
- insertIfAbsent :: (Eq k, Hashable k) => k -> v -> Map k v -> IO Bool
- lookup :: (Eq k, Hashable k) => k -> Map k v -> IO (Maybe v)
- fromList :: (Eq k, Hashable k) => [(k, v)] -> IO (Map k v)
- unsafeToList :: Map k v -> IO [(k, v)]
Documentation
Construction
Modification
Query
lookup :: (Eq k, Hashable k) => k -> Map k v -> IO (Maybe v) Source #
O(log n). Return the value associated with the given key, or Nothing
.
Lists
fromList :: (Eq k, Hashable k) => [(k, v)] -> IO (Map k v) Source #
O(n * log n). Construct a map from a list of key/value pairs.
unsafeToList :: Map k v -> IO [(k, v)] Source #
O(n). Unsafely convert the map to a list of key/value pairs.
WARNING: unsafeToList
makes no atomicity guarantees. Concurrent
changes to the map will lead to inconsistent results.