HashTable< Key, Value > Class Template Reference#include <tDictionary.h>
Inheritance diagram for HashTable< Key, Value >: ![]() Detailed Description
A HashTable template class.
|
Public Types | |
typedef Pair | ValueType |
typedef Pair & | Reference |
typedef const Pair & | ConstReference |
typedef _Iterator< Pair, Node, HashTable > | Iterator |
typedef _Iterator< const Pair, const Node, const HashTable > | ConstIterator |
typedef S32 | DifferenceType |
typedef U32 | SizeType |
Public Member Functions | |
HashTable () | |
~HashTable () | |
HashTable (const HashTable &p) | |
U32 | size () const |
Return the number of elements. | |
U32 | tableSize () const |
Return the size of the hash bucket table. | |
void | clear () |
Empty the HashTable. | |
void | resize (U32 size) |
Resize the bucket table for an estimated number of elements. | |
bool | isEmpty () const |
Returns true if the table is empty. | |
F32 | collisions () const |
Returns the average number of nodes per bucket. | |
Iterator | insertEqual (const Key &key, const Value &) |
Insert the key value pair and allow duplicates. | |
Iterator | insertUnique (const Key &key, const Value &) |
Insert the key value pair but don't insert duplicates. | |
void | erase (Iterator) |
Erase the given entry. | |
void | erase (const Key &key) |
Erase all matching keys from the table. | |
void | erase (const Key &key, const Value &value) |
Erase entry for this key-value pair. | |
Iterator | findOrInsert (const Key &key) |
Find the key, or insert a one if it doesn't exist. | |
Iterator | find (const Key &) |
Find the first entry for the given key. | |
ConstIterator | find (const Key &) const |
Find the first entry for the given key. | |
bool | find (const Key &key, Value &value) |
Find the first entry for the given key. | |
S32 | count (const Key &) |
Count the number of matching keys in the table. | |
Iterator | begin () |
Iterator to first element. | |
ConstIterator | begin () const |
Iterator to first element. | |
Iterator | end () |
Iterator to last element + 1. | |
ConstIterator | end () const |
Iterator to last element + 1. | |
void | operator= (const HashTable &p) |
Private Member Functions | |
U32 | _hash (const Key &key) const |
U32 | _index (const Key &key) const |
Node * | _next (U32 index) const |
void | _resize (U32 size) |
void | _destroy () |
Private Attributes | |
Node ** | mTable |
Hash table. | |
S32 | mTableSize |
Hash table size. | |
U32 | mSize |
Number of keys in the table. | |
Classes | |
class | _Iterator |
struct | Node |
struct | Pair |
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
typedef const Pair& HashTable< Key, Value >::ConstReference |
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
typedef _Iterator<Pair,Node,HashTable> HashTable< Key, Value >::Iterator |
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
typedef _Iterator<const Pair,const Node,const HashTable> HashTable< Key, Value >::ConstIterator |
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
typedef S32 HashTable< Key, Value >::DifferenceType |
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
HashTable< Key, Value >::HashTable | ( | const HashTable< Key, Value > & | p | ) |
U32 HashTable< Key, Value >::_hash | ( | const Key & | key | ) | const [inline, private] |
U32 HashTable< Key, Value >::_index | ( | const Key & | key | ) | const [inline, private] |
HashTable< Key, Value >::Node * HashTable< Key, Value >::_next | ( | U32 | index | ) | const [private] |
Return the number of elements.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
Return the size of the hash bucket table.
Empty the HashTable.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
Resize the bucket table for an estimated number of elements.
This method will optimize the hash bucket table size to hold the given number of elements. The size argument is a hint, and will not be the exact size of the table. If the table is sized down below it's optimal size, the next insert will cause it to be resized again. Normally this function is used to avoid resizes when the number of elements that will be inserted is known in advance.
Returns true if the table is empty.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
Returns the average number of nodes per bucket.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::insertEqual | ( | const Key & | key, | |
const Value & | x | |||
) |
Insert the key value pair and allow duplicates.
This insert method allows duplicate keys. Keys are grouped together but are not sorted.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::insertUnique | ( | const Key & | key, | |
const Value & | x | |||
) |
Insert the key value pair but don't insert duplicates.
This insert method does not insert duplicate keys. If the key already exists in the table the function will fail and end() is returned.
Erase the given entry.
Erase all matching keys from the table.
void HashTable< Key, Value >::erase | ( | const Key & | key, | |
const Value & | value | |||
) |
Erase entry for this key-value pair.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::findOrInsert | ( | const Key & | key | ) |
Find the key, or insert a one if it doesn't exist.
Returns the first key in the table that matches, or inserts one if there are none.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::find | ( | const Key & | ) |
Find the first entry for the given key.
HashTable< Key, Value >::ConstIterator HashTable< Key, Value >::find | ( | const Key & | ) | const |
Find the first entry for the given key.
bool HashTable< Key, Value >::find | ( | const Key & | key, | |
Value & | value | |||
) |
Find the first entry for the given key.
Count the number of matching keys in the table.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::begin | ( | ) | [inline] |
Iterator to first element.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
HashTable< Key, Value >::ConstIterator HashTable< Key, Value >::begin | ( | ) | const [inline] |
Iterator to first element.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
HashTable< Key, Value >::Iterator HashTable< Key, Value >::end | ( | ) | [inline] |
Iterator to last element + 1.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
HashTable< Key, Value >::ConstIterator HashTable< Key, Value >::end | ( | ) | const [inline] |
Iterator to last element + 1.
Reimplemented in Map< String, unsigned int >, and Map< GFXShader *, BasicLightManager::LightingShaderConstants >.
void HashTable< Key, Value >::operator= | ( | const HashTable< Key, Value > & | p | ) |
S32 HashTable< Key, Value >::mTableSize [private] |
Hash table size.
Number of keys in the table.