HashTable< Key, Value, Hasher, KeyEqual > Class Template Reference

#include <hashtable.h>

Inheritance diagram for HashTable< Key, Value, Hasher, KeyEqual >:
Inheritance graph
[legend]
Collaboration diagram for HashTable< Key, Value, Hasher, KeyEqual >:
Collaboration graph
[legend]

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.
Valueoperator[] (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 BucketNodeBucket

Private Member Functions

BucketNodenode_create (hash_type hash, const Key &key, const Value &value)
void node_destroy (BucketNode *node)
BucketNodegetFirst ()
BucketNodegetLast ()
void initialise ()
hash_type hashKey (const Key &key)
std::size_t getBucketId (hash_type hash) const
BucketgetBucket (hash_type hash)
BucketNodebucket_find (Bucket bucket, hash_type hash, const Key &key)
BucketNodebucket_insert (Bucket &bucket, BucketNode *node)
BucketNodebucket_next (Bucket &bucket)
void buckets_resize (std::size_t count)
void size_increment ()
void size_decrement ()
 HashTable (const HashTable &other)
HashTableoperator= (const HashTable &other)

Static Private Member Functions

static Bucketbuckets_new (std::size_t count)
static void buckets_delete (Bucket *buckets)

Private Attributes

std::size_t m_bucketCount
Bucketm_buckets
std::size_t m_size
HashTableDetail::BucketNodeBase m_list

Detailed Description

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
class HashTable< Key, Value, Hasher, KeyEqual >

A hash-table container which maps keys to values.

Parameters:
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.


Member Typedef Documentation

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::Bucket [private]

Definition at line 177 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef HashTableDetail::BucketNode<Key, Value, hash_type> HashTable< Key, Value, Hasher, KeyEqual >::BucketNode [private]

Definition at line 168 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef Hasher::hash_type HashTable< Key, Value, Hasher, KeyEqual >::hash_type [private]

Definition at line 166 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef HashTableDetail::BucketIterator<Key, Value, hash_type> HashTable< Key, Value, Hasher, KeyEqual >::iterator

Definition at line 203 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef HashTableDetail::KeyValue<Key, Value> HashTable< Key, Value, Hasher, KeyEqual >::KeyValue [private]

Definition at line 167 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
typedef KeyValue HashTable< Key, Value, Hasher, KeyEqual >::value_type

Definition at line 202 of file hashtable.h.


Constructor & Destructor Documentation

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTable< Key, Value, Hasher, KeyEqual >::HashTable ( const HashTable< Key, Value, Hasher, KeyEqual > &  other  )  [private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTable< Key, Value, Hasher, KeyEqual >::HashTable (  )  [inline]

Definition at line 281 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTable< Key, Value, Hasher, KeyEqual >::HashTable ( std::size_t  bucketCount  )  [inline]

Definition at line 284 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTable< Key, Value, Hasher, KeyEqual >::~HashTable (  )  [inline]

Definition at line 287 of file hashtable.h.


Member Function Documentation

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
iterator HashTable< Key, Value, Hasher, KeyEqual >::begin (  )  [inline]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_find ( Bucket  bucket,
hash_type  hash,
const Key &  key 
) [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_insert ( Bucket bucket,
BucketNode node 
) [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::bucket_next ( Bucket bucket  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
static void HashTable< Key, Value, Hasher, KeyEqual >::buckets_delete ( Bucket buckets  )  [inline, static, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
static Bucket* HashTable< Key, Value, Hasher, KeyEqual >::buckets_new ( std::size_t  count  )  [inline, static, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
void HashTable< Key, Value, Hasher, KeyEqual >::buckets_resize ( std::size_t  count  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
bool HashTable< Key, Value, Hasher, KeyEqual >::empty (  )  const [inline]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
iterator HashTable< Key, Value, Hasher, KeyEqual >::end (  )  [inline]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
Bucket& HashTable< Key, Value, Hasher, KeyEqual >::getBucket ( hash_type  hash  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::getBucketId ( hash_type  hash  )  const [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::getFirst (  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::getLast (  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
hash_type HashTable< Key, Value, Hasher, KeyEqual >::hashKey ( const Key &  key  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
void HashTable< Key, Value, Hasher, KeyEqual >::initialise (  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
BucketNode* HashTable< Key, Value, Hasher, KeyEqual >::node_create ( hash_type  hash,
const Key &  key,
const Value value 
) [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
void HashTable< Key, Value, Hasher, KeyEqual >::node_destroy ( BucketNode node  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTable& HashTable< Key, Value, Hasher, KeyEqual >::operator= ( const HashTable< Key, Value, Hasher, KeyEqual > &  other  )  [private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::size (  )  const [inline]

Definition at line 306 of file hashtable.h.

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
void HashTable< Key, Value, Hasher, KeyEqual >::size_increment (  )  [inline, private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
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().


Field Documentation

template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::m_bucketCount [private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
Bucket* HashTable< Key, Value, Hasher, KeyEqual >::m_buckets [private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
HashTableDetail::BucketNodeBase HashTable< Key, Value, Hasher, KeyEqual >::m_list [private]
template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key>>
std::size_t HashTable< Key, Value, Hasher, KeyEqual >::m_size [private]

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2