-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Non-blocking concurrent map
--   
--   A non-blocking concurrent map implementation based on <i>lock-free
--   concurrent hash tries</i> (aka <i>Ctries</i>).
@package ctrie
@version 0.2


-- | A non-blocking concurrent map from hashable keys to values.
--   
--   The implementation is based on <i>lock-free concurrent hash tries</i>
--   (aka <i>Ctries</i>) as described by:
--   
--   <ul>
--   <li>Aleksander Prokopec, Phil Bagwell, Martin Odersky, "<i>Cache-Aware
--   Lock-Free Concurent Hash Tries</i>"</li>
--   <li>Aleksander Prokopec, Nathan G. Bronson, Phil Bagwell, Martin
--   Odersky "<i>Concurrent Tries with Efficient Non-Blocking
--   Snapshots</i>"</li>
--   </ul>
--   
--   Operations have a worst-case complexity of <i>O(log n)</i>, with a
--   base equal to the size of the native <a>Word</a>.
module Control.Concurrent.Map

-- | A map from keys <tt>k</tt> to values <tt>v</tt>.
data Map k v

-- | <i>O(1)</i>. Construct an empty map.
empty :: IO (Map k v)

-- | <i>O(log n)</i>. Associate the given value with the given key. If the
--   key is already present in the map, the old value is replaced. Returns
--   <a>True</a> if the value was inserted, <a>False</a> if it was
--   replaced.
insert :: (Eq k, Hashable k) => k -> v -> Map k v -> IO Bool

-- | <i>O(log n)</i>. Remove the given key and its associated value from
--   the map, if present. Returns <a>True</a> if the value was deleted,
--   <a>False</a> otherwise.
delete :: (Eq k, Hashable k) => k -> Map k v -> IO Bool

-- | <i>O(log n)</i>. Associate the given value with the given key. If the
--   key is already present in the map, don't change the value. Returns
--   <a>True</a> if the value was inserted, <a>False</a> otherwise.
insertIfAbsent :: (Eq k, Hashable k) => k -> v -> Map k v -> IO Bool

-- | <i>O(log n)</i>. Return the value associated with the given key, or
--   <a>Nothing</a>.
lookup :: (Eq k, Hashable k) => k -> Map k v -> IO (Maybe v)

-- | <i>O(n * log n)</i>. Construct a map from a list of key/value pairs.
fromList :: (Eq k, Hashable k) => [(k, v)] -> IO (Map k v)

-- | <i>O(n)</i>. Unsafely convert the map to a list of key/value pairs.
--   
--   WARNING: <a>unsafeToList</a> makes no atomicity guarantees. Concurrent
--   changes to the map will lead to inconsistent results.
unsafeToList :: Map k v -> IO [(k, v)]
instance (GHC.Show.Show k, GHC.Show.Show v) => GHC.Show.Show (Control.Concurrent.Map.SNode k v)
instance (GHC.Classes.Eq k, GHC.Classes.Eq v) => GHC.Classes.Eq (Control.Concurrent.Map.SNode k v)
