forbidden-fruit-0.1.0: A library accelerates imperative style programming.

Copyright(C) 2015, Yu Fukuzawa
LicenseBSD3
Maintainerminpou.primer@email.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Control.Imperative.Hash

Contents

Description

 

Synopsis

Documentation

A mutable hashtable.

There are two basic operation exported from the Control.Imperative module.

ref
O(1). lookup the value of a hashtable at the given key.
assign
O(1). insert the value at the given key.

Types

data HashTable m k v Source

Instances

(HashKey k, MHash m) => Indexable (HashTable m k v) 
type Element (HashTable m k v) = Ref m v 
type IndexType (HashTable m k v) = k 

type MonadHash m = (MonadBase (BaseEff m) m, MHash (BaseEff m)) Source

Useful constraint synonym for hashtable operations.

class (Eq k, Hashable k) => HashKey k Source

Instances

(Eq k, Hashable k) => HashKey k 

Operations

new :: MonadHash m => m (HashTable (BaseEff m) k v) Source

O(1). Create an empty hashtable with a given size.

newSized :: MonadHash m => Int -> m (HashTable (BaseEff m) k v) Source

O(1). Create an empty hashtable with a given size.

delete :: (HashKey k, MonadHash m) => HashTable (BaseEff m) k v -> k -> m () Source

O(n) worst case, O(1) amortized. Delete key-value mapping in a hashtable.

fromList :: (HashKey k, MonadHash m) => [(k, v)] -> m (HashTable (BaseEff m) k v) Source

O(n). Create a hashtable from an associative list.

toList :: (HashKey k, MonadHash m) => HashTable (BaseEff m) k v -> m [(k, v)] Source

O(n). Convert the hashtable to a nested associative list.