#include <hashtable.h>
Public Types | |
typedef KeyValue | value_type |
typedef HashTableDetail::BucketIterator < Key, Value, hash_type > | iterator |
Public Member Functions | |
HashTable () | |
HashTable (std::size_t bucketCount) | |
~HashTable () | |
iterator | begin () |
iterator | end () |
bool | empty () const |
std::size_t | size () const |
iterator | find (const Key &key) |
Returns an iterator pointing to the value associated with key if it is contained by the hash-table, else end() . | |
iterator | insert (const Key &key, const Value &value) |
Adds value to the hash-table associated with key if it does not exist. | |
void | erase (iterator i) |
Removes the value pointed to by i from the hash-table. | |
Value & | operator[] (const Key &key) |
Returns the value identified by key if it is contained by the hash-table, else inserts and returns a new default-constructed value associated with key . | |
void | erase (const Key &key) |
Removes the value associated with key from the hash-table. | |
void | swap (HashTable &other) |
Swaps the contents of the hash-table with other . | |
void | clear () |
Removes all values from the hash-table. | |
Private Types | |
typedef Hasher::hash_type | hash_type |
typedef HashTableDetail::KeyValue< Key, Value > | KeyValue |
typedef HashTableDetail::BucketNode < Key, Value, hash_type > | BucketNode |
typedef BucketNode * | Bucket |
Private Member Functions | |
BucketNode * | node_create (hash_type hash, const Key &key, const Value &value) |
void | node_destroy (BucketNode *node) |
BucketNode * | getFirst () |
BucketNode * | getLast () |
void | initialise () |
hash_type | hashKey (const Key &key) |
std::size_t | getBucketId (hash_type hash) const |
Bucket & | getBucket (hash_type hash) |
BucketNode * | bucket_find (Bucket bucket, hash_type hash, const Key &key) |
BucketNode * | bucket_insert (Bucket &bucket, BucketNode *node) |
BucketNode * | bucket_next (Bucket &bucket) |
void | buckets_resize (std::size_t count) |
void | size_increment () |
void | size_decrement () |
HashTable (const HashTable &other) | |
HashTable & | operator= (const HashTable &other) |
Static Private Member Functions | |
static Bucket * | buckets_new (std::size_t count) |
static void | buckets_delete (Bucket *buckets) |
Private Attributes | |
std::size_t | m_bucketCount |
Bucket * | m_buckets |
std::size_t | m_size |
HashTableDetail::BucketNodeBase | m_list |
A hash-table container which maps keys to values.
Key | Uniquely identifies a value. Must provide a copy-constructor. | |
Value | The value to be stored . Must provide a default-constructor and a copy-constructor. | |
Hasher | Must provide 'stdsize_t operator()(const Key&) const' which always returns the same result if the same argument is given. | |
KeyEqual | Must provide 'bool operator==(const Key&, const Key&) const' which returns true only if both arguments are equal. |
Definition at line 165 of file hashtable.h.
typedef BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::Bucket [private] |
Definition at line 177 of file hashtable.h.
typedef HashTableDetail::BucketNode<Key, Value, hash_type> HashTable< Key, Value, Hasher, KeyEqual >::BucketNode [private] |
Definition at line 168 of file hashtable.h.
typedef Hasher::hash_type HashTable< Key, Value, Hasher, KeyEqual >::hash_type [private] |
Definition at line 166 of file hashtable.h.
typedef HashTableDetail::BucketIterator<Key, Value, hash_type> HashTable< Key, Value, Hasher, KeyEqual >::iterator |
Definition at line 203 of file hashtable.h.
typedef HashTableDetail::KeyValue<Key, Value> HashTable< Key, Value, Hasher, KeyEqual >::KeyValue [private] |
Definition at line 167 of file hashtable.h.
typedef KeyValue HashTable< Key, Value, Hasher, KeyEqual >::value_type |
Definition at line 202 of file hashtable.h.
HashTable< Key, Value, Hasher, KeyEqual >::HashTable | ( | const HashTable< Key, Value, Hasher, KeyEqual > & | other | ) | [private] |
HashTable< Key, Value, Hasher, KeyEqual >::HashTable | ( | ) | [inline] |
Definition at line 281 of file hashtable.h.
HashTable< Key, Value, Hasher, KeyEqual >::HashTable | ( | std::size_t | bucketCount | ) | [inline] |
Definition at line 284 of file hashtable.h.
HashTable< Key, Value, Hasher, KeyEqual >::~HashTable | ( | ) | [inline] |
Definition at line 287 of file hashtable.h.
iterator HashTable< Key, Value, Hasher, KeyEqual >::begin | ( | ) | [inline] |
Definition at line 296 of file hashtable.h.
Referenced by HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::begin().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_find | ( | Bucket | bucket, | |
hash_type | hash, | |||
const Key & | key | |||
) | [inline, private] |
Definition at line 220 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::find(), HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_insert | ( | Bucket & | bucket, | |
BucketNode * | node | |||
) | [inline, private] |
Definition at line 235 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_next | ( | Bucket & | bucket | ) | [inline, private] |
Definition at line 241 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_insert().
static void HashTable< Key, Value, Hasher, KeyEqual >::buckets_delete | ( | Bucket * | buckets | ) | [inline, static, private] |
Definition at line 184 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), and HashTable< Key, Element, Hasher, KeyEqual >::~HashTable().
static Bucket* HashTable< Key, Value, Hasher, KeyEqual >::buckets_new | ( | std::size_t | count | ) | [inline, static, private] |
Definition at line 179 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize().
void HashTable< Key, Value, Hasher, KeyEqual >::buckets_resize | ( | std::size_t | count | ) | [inline, private] |
Definition at line 251 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::size_increment().
void HashTable< Key, Value, Hasher, KeyEqual >::clear | ( | ) | [inline] |
Removes all values from the hash-table.
Definition at line 388 of file hashtable.h.
Referenced by HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::clear().
bool HashTable< Key, Value, Hasher, KeyEqual >::empty | ( | ) | const [inline] |
Definition at line 303 of file hashtable.h.
Referenced by HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::empty().
iterator HashTable< Key, Value, Hasher, KeyEqual >::end | ( | ) | [inline] |
Definition at line 299 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_find(), HashTable< Key, Element, Hasher, KeyEqual >::bucket_next(), HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::end(), HashTable< Key, Element, Hasher, KeyEqual >::find(), and HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::release().
void HashTable< Key, Value, Hasher, KeyEqual >::erase | ( | const Key & | key | ) | [inline] |
Removes the value associated with key
from the hash-table.
Definition at line 377 of file hashtable.h.
void HashTable< Key, Value, Hasher, KeyEqual >::erase | ( | iterator | i | ) | [inline] |
Removes the value pointed to by i
from the hash-table.
i
must be a deferenceable iterator into the hash-table.
Definition at line 345 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::erase(), and HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::release().
iterator HashTable< Key, Value, Hasher, KeyEqual >::find | ( | const Key & | key | ) | [inline] |
Returns an iterator pointing to the value associated with key
if it is contained by the hash-table, else end()
.
Definition at line 311 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::erase(), HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::find(), and HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::release().
Bucket& HashTable< Key, Value, Hasher, KeyEqual >::getBucket | ( | hash_type | hash | ) | [inline, private] |
Definition at line 217 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), HashTable< Key, Element, Hasher, KeyEqual >::erase(), HashTable< Key, Element, Hasher, KeyEqual >::find(), HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::getBucketId | ( | hash_type | hash | ) | const [inline, private] |
Definition at line 214 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_find(), and HashTable< Key, Element, Hasher, KeyEqual >::getBucket().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::getFirst | ( | ) | [inline, private] |
Definition at line 193 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::begin(), HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), and HashTable< Key, Element, Hasher, KeyEqual >::~HashTable().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::getLast | ( | ) | [inline, private] |
Definition at line 196 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_next(), HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), HashTable< Key, Element, Hasher, KeyEqual >::end(), HashTable< Key, Element, Hasher, KeyEqual >::erase(), and HashTable< Key, Element, Hasher, KeyEqual >::~HashTable().
hash_type HashTable< Key, Value, Hasher, KeyEqual >::hashKey | ( | const Key & | key | ) | [inline, private] |
Definition at line 210 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::find(), HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
void HashTable< Key, Value, Hasher, KeyEqual >::initialise | ( | ) | [inline, private] |
Definition at line 207 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), and HashTable< Key, Element, Hasher, KeyEqual >::HashTable().
iterator HashTable< Key, Value, Hasher, KeyEqual >::insert | ( | const Key & | key, | |
const Value & | value | |||
) | [inline] |
Adds value
to the hash-table associated with key
if it does not exist.
Definition at line 326 of file hashtable.h.
Referenced by HashedCache< Key, Cached, Hasher, KeyEqual, CreationPolicy >::capture().
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::node_create | ( | hash_type | hash, | |
const Key & | key, | |||
const Value & | value | |||
) | [inline, private] |
Definition at line 170 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
void HashTable< Key, Value, Hasher, KeyEqual >::node_destroy | ( | BucketNode * | node | ) | [inline, private] |
Definition at line 173 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::erase(), and HashTable< Key, Element, Hasher, KeyEqual >::~HashTable().
HashTable& HashTable< Key, Value, Hasher, KeyEqual >::operator= | ( | const HashTable< Key, Value, Hasher, KeyEqual > & | other | ) | [private] |
Value& HashTable< Key, Value, Hasher, KeyEqual >::operator[] | ( | const Key & | key | ) | [inline] |
Returns the value identified by key
if it is contained by the hash-table, else inserts and returns a new default-constructed value associated with key
.
Definition at line 362 of file hashtable.h.
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::size | ( | ) | const [inline] |
Definition at line 306 of file hashtable.h.
void HashTable< Key, Value, Hasher, KeyEqual >::size_decrement | ( | ) | [inline, private] |
Definition at line 274 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::erase().
void HashTable< Key, Value, Hasher, KeyEqual >::size_increment | ( | ) | [inline, private] |
Definition at line 268 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::insert(), and HashTable< Key, Element, Hasher, KeyEqual >::operator[]().
void HashTable< Key, Value, Hasher, KeyEqual >::swap | ( | HashTable< Key, Value, Hasher, KeyEqual > & | other | ) | [inline] |
Swaps the contents of the hash-table with other
.
Definition at line 381 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::clear(), and HashTable< Key, Element, Hasher, KeyEqual >::swap().
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::m_bucketCount [private] |
Definition at line 188 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_next(), HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), HashTable< Key, Element, Hasher, KeyEqual >::find(), HashTable< Key, Element, Hasher, KeyEqual >::getBucketId(), HashTable< Key, Element, Hasher, KeyEqual >::insert(), HashTable< Key, Element, Hasher, KeyEqual >::operator[](), HashTable< Key, Element, Hasher, KeyEqual >::size_increment(), and HashTable< Key, Element, Hasher, KeyEqual >::swap().
Bucket* HashTable< Key, Value, Hasher, KeyEqual >::m_buckets [private] |
Definition at line 189 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::bucket_next(), HashTable< Key, Element, Hasher, KeyEqual >::buckets_resize(), HashTable< Key, Element, Hasher, KeyEqual >::getBucket(), HashTable< Key, Element, Hasher, KeyEqual >::swap(), and HashTable< Key, Element, Hasher, KeyEqual >::~HashTable().
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::m_size [private] |
Definition at line 190 of file hashtable.h.
Referenced by HashTable< Key, Element, Hasher, KeyEqual >::empty(), HashTable< Key, Element, Hasher, KeyEqual >::size(), HashTable< Key, Element, Hasher, KeyEqual >::size_decrement(), HashTable< Key, Element, Hasher, KeyEqual >::size_increment(), and HashTable< Key, Element, Hasher, KeyEqual >::swap().