Torque2D Reference
|
#include <hashTable.h>
Classes | |
class | _Iterator |
struct | Pair |
Public Types | |
typedef Pair | ValueType |
typedef Pair & | Reference |
typedef const Pair & | ConstReference |
typedef S32 | DifferenceType |
typedef U32 | SizeType |
typedef _Iterator< Pair, Node, HashTable > | iterator |
typedef _Iterator< const Pair, const Node, const HashTable > | const_iterator |
Public Member Functions | |
HashTable () | |
~HashTable () | |
HashTable (const HashTable &p) | |
U32 | size () const |
Return the number of elements. More... | |
U32 | tableSize () const |
Return the size of the hash bucket table. More... | |
void | clear () |
Empty the HashTable. More... | |
void | resize (U32 size) |
bool | isEmpty () const |
Returns true if the table is empty. More... | |
F32 | collisions () const |
Returns the average number of nodes per bucket. More... | |
iterator | insertEqual (const Key &key, const Value &) |
iterator | insertUnique (const Key &key, const Value &) |
void | erase (iterator) |
Erase the given entry. More... | |
void | erase (const Key &key) |
Erase all matching keys from the table. More... | |
iterator | findOrInsert (const Key &key) |
iterator | find (const Key &) |
Find the first entry for the given key. More... | |
const_iterator | find (const Key &) const |
Find the first entry for the given key. More... | |
S32 | count (const Key &) |
Count the number of matching keys in the table. More... | |
iterator | begin () |
iterator to first element More... | |
const_iterator | begin () const |
iterator to first element More... | |
iterator | end () |
iterator to last element + 1 More... | |
const_iterator | end () const |
iterator to last element + 1 More... | |
void | operator= (const HashTable &p) |
A HashTable template class.
The hash table class maps between a key and an associated value. Access using the key is performed using a hash table. The class provides methods for both unique and equal keys. The global ::hash(Type) function is used for hashing, see util/hash.h
typedef _Iterator<const Pair,const Node,const HashTable> const_iterator |
typedef const Pair& ConstReference |
typedef S32 DifferenceType |
typedef U32 SizeType |
HashTable | ( | ) |
~HashTable | ( | ) |
|
inline |
iterator to first element
|
inline |
Empty the HashTable.
|
inline |
Returns the average number of nodes per bucket.
S32 count | ( | const Key & | key | ) |
Count the number of matching keys in the table.
|
inline |
iterator to last element + 1
void erase | ( | iterator | node | ) |
Erase the given entry.
void erase | ( | const Key & | key | ) |
Erase all matching keys from the table.
const_iterator find | ( | const Key & | ) | const |
Find the first entry for the given 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.
Insert the key value pair and allow duplicates. This insert method allows duplicate keys. Keys are grouped together but are not sorted.
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.
|
inline |
Returns true if the table is empty.
void operator= | ( | const HashTable< Key, Value > & | p | ) |
|
inline |
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.
|
inline |
Return the number of elements.
|
inline |
Return the size of the hash bucket table.