| Safe Haskell | None |
|---|
HashtablesPlus
- type Map a k v = a RealWorld k v
- data Set a v
- data HashRefSet a v
- data Multimap a k s
- data Sized c
- type Algorithm = HashTable
- 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
- toList :: Collection c => c -> IO [Row c]
- class Collection c => Lookup c where
- class Collection c => TraverseMulti c where
- traverseMulti :: c -> MultiKey c -> (Value c -> IO ()) -> IO ()
- lookupMulti :: TraverseMulti c => 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
Data Structures
data HashRefSet a v Source
A specialized set of HashRefs.
a is the underlying Algorithm,
v is the item.
E.g.:
type LinearHashRefSet v =HashRefSetLinearv
Instances
| Algorithm a => Delete (HashRefSet a v) | |
| Algorithm a => Insert (HashRefSet a v) | |
| Algorithm a => Elem (HashRefSet a v) | |
| Algorithm a => Collection (HashRefSet a v) |
A multimap with an underlying Algorithm a, a key k and
a set implementation s.
E.g.:
type BasicMultimap k v =MultimapBasick (SetBasicv)
If a Sized implementation of set is specified,
a more space efficient instance of Delete will be used. E.g.:
Multimap Basic k (Sized (Set Basic v))
Instances
| (Algorithm a, Key k, Delete s) => Delete (Multimap a k (Sized s)) | |
| (Algorithm a, Key k, Delete s) => Delete (Multimap a k s) | |
| (Algorithm a, Key k, Insert s) => Insert (Multimap a k s) | |
| (Algorithm a, Key k, Elem s) => Elem (Multimap a k s) | |
| (Algorithm a, Key k, Collection s, ~ * (Value s) (Row s)) => TraverseMulti (Multimap a k s) | |
| (Algorithm a, Key k, Collection s) => Collection (Multimap a k s) |
A wrapper over a Collection,
which adds null and size functions of O(1) complexity.
E.g.:
type SizedLinearTable k v =Sized(MapLineark 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) | |
| TraverseMulti c => TraverseMulti (Sized c) | |
| Lookup c => Lookup (Sized c) | |
| Collection c => Collection (Sized c) | |
| (Algorithm a, Key k, Delete s) => Delete (Multimap a k (Sized s)) |
Algorithm
Implementations
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.
The implementation with a low performance, but also a low memory consumption.
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.
traverse :: c -> (Row c -> IO ()) -> IO ()Source
Traverse thru all the rows of with side effects.
Instances
| Collection c => Collection (Sized c) | |
| Algorithm a => Collection (HashRefSet a v) | |
| (Algorithm a, Key v) => Collection (Set a v) | |
| (Algorithm a, Key k, Collection s) => Collection (Multimap a k s) | |
| (Algorithm a, Key k) => Collection (Map a k v) |
toList :: Collection c => c -> IO [Row c]Source
O(n). Convert a collection to a list.
class Collection c => Lookup c whereSource
class Collection c => TraverseMulti c whereSource
Methods
traverseMulti :: c -> MultiKey c -> (Value c -> IO ()) -> IO ()Source
Traverse items matching a non-unique key.
Instances
| TraverseMulti c => TraverseMulti (Sized c) | |
| (Algorithm a, Key k, Collection s, ~ * (Value s) (Row s)) => TraverseMulti (Multimap a k s) |
lookupMulti :: TraverseMulti c => c -> MultiKey c -> IO [Value c]Source
Lookup multiple items by a non-unique key.
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) |