| Safe Haskell | None |
|---|
HashtablesPlus
- data Table t k v
- data Set t a
- data HashRefSet t a
- data MultiTable t k s
- data Sized c
- type Basic = HashTable
- type Cuckoo = HashTable
- type Linear = HashTable
- type Key k = (Hashable k, Eq k)
- type family Row c
- type family UniqueKey c
- type family MultiKey c
- type family Value c
- class Collection c where
- class Collection c => Lookup c where
- class Collection c => LookupMulti c where
- lookupMulti :: c -> MultiKey c -> IO [Value c]
- class Collection c => Elem c where
- class Collection c => Insert c where
- class Collection c => Delete c where
- class Collection c => Size c where
- class Collection c => Null c where
- forM_ :: Collection c => c -> (Row c -> IO ()) -> IO ()
- toList :: Collection c => c -> IO [Row c]
Data Structures
data HashRefSet t a Source
A specialized set of HashRefs.
t is the underlying HashTable implementation,
a is the item.
E.g.:
type LinearHashRefSet a =HashRefSetLineara
Instances
| HashTable t => Delete (HashRefSet t a) | |
| HashTable t => Insert (HashRefSet t a) | |
| HashTable t => Elem (HashRefSet t a) | |
| HashTable t => Collection (HashRefSet t a) |
data MultiTable t k s Source
A multitable (or multimap) with underlying HashTable t, key k and
a set implementation s.
E.g.:
type BasicMultiTable k v =MultiTableBasick (SetBasicv)
If a Sized implementation of set is specified,
a more space efficient instance of Delete will be used. E.g.:
MultiTable Basic k (Sized (Set Basic v))
Instances
| (HashTable t, Key k, Delete c) => Delete (MultiTable t k (Sized c)) | |
| (HashTable t, Key k, Delete c) => Delete (MultiTable t k c) | |
| (HashTable t, Key k, Insert s) => Insert (MultiTable t k s) | |
| (HashTable t, Key k, Elem s) => Elem (MultiTable t k s) | |
| (HashTable t, Key k, Collection s, ~ * (Value s) (Row s)) => LookupMulti (MultiTable t k s) | |
| (HashTable t, Key k, Collection s) => Collection (MultiTable t k s) |
A wrapper over a Collection,
which adds null and size functions of O(1) complexity.
E.g.:
type SizedLinearTable k v =Sized(TableLineark v)
Instances
| Collection c => Null (Sized c) | |
| Collection c => Size (Sized c) | |
| Delete c => Delete (Sized c) | |
| Insert c => Insert (Sized c) | |
| Elem c => Elem (Sized c) | |
| LookupMulti c => LookupMulti (Sized c) | |
| Lookup c => Lookup (Sized c) | |
| Collection c => Collection (Sized c) | |
| (HashTable t, Key k, Delete c) => Delete (MultiTable t k (Sized c)) |
HashTable Implementations
These are aliases of implementations of a class HashTable,
which provide different performance and memory consumption characteristics.
They are used as parameters to data structures.
For more info refer to the documentation on aliased types.
Interface
A row of a collection. For tables and multitables it's a key-value pair, for sets it's just the item.
type family UniqueKey c Source
A unique row identifier. For tables it's a key, for multitables it's a key-value pair, for sets it's the item itself.
A non-unique row identifier. For tables and sets there is none, for multitables it's a key.
An item of a collection. For tables and multitables it's a value (from the key-value pair), for sets it's the item.
class Collection c whereSource
Methods
Create a new collection.
foldM :: c -> r -> (r -> Row c -> IO r) -> IO rSource
Strictly fold over the rows.
Instances
| Collection c => Collection (Sized c) | |
| HashTable t => Collection (HashRefSet t a) | |
| (HashTable t, Key a) => Collection (Set t a) | |
| (HashTable t, Key k, Collection s) => Collection (MultiTable t k s) | |
| (HashTable t, Key k) => Collection (Table t k v) |
class Collection c => Lookup c whereSource
class Collection c => LookupMulti c whereSource
Methods
lookupMulti :: c -> MultiKey c -> IO [Value c]Source
Lookup multiple items by a non-unique key.
Instances
| LookupMulti c => LookupMulti (Sized c) | |
| (HashTable t, Key k, Collection s, ~ * (Value s) (Row s)) => LookupMulti (MultiTable t k s) |
class Collection c => Elem c whereSource
class Collection c => Insert c whereSource
Methods
insert :: c -> Row c -> IO BoolSource
Insert a row into a collection.
Returns a boolean signifying whether a new row has been inserted.
Note that if a row has been replaced it returns False.
insertFast :: c -> Row c -> IO ()Source
Same as insert, but avoiding the calculation of the operation result.
class Collection c => Delete c whereSource
class Collection c => Size c whereSource
Instances
| Collection c => Size (Sized c) |
class Collection c => Null c whereSource
Instances
| Collection c => Null (Sized c) |
forM_ :: Collection c => c -> (Row c -> IO ()) -> IO ()Source
Traverse thru all the rows of a collection with side effects.
toList :: Collection c => c -> IO [Row c]Source
O(n). Convert a collection to a list.