|
Torque2D Reference
|
#include <hashTable.h>
Inheritance diagram for HashTable< Key, Value >: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. | |
| U32 | tableSize () const |
| Return the size of the hash bucket table. | |
| void | clear () |
| Empty the HashTable. | |
| void | resize (U32 size) |
| 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 &) |
| iterator | insertUnique (const Key &key, const Value &) |
| void | erase (iterator) |
| Erase the given entry. | |
| void | erase (const Key &key) |
| Erase all matching keys from the table. | |
| iterator | findOrInsert (const Key &key) |
| iterator | find (const Key &) |
| Find the first entry for the given key. | |
| const_iterator | find (const Key &) const |
| 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 | |
| const_iterator | begin () const |
| iterator to first element | |
| iterator | end () |
| iterator to last element + 1 | |
| const_iterator | end () const |
| iterator to last element + 1 | |
| 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 |
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
|
inline |
iterator to last element + 1
| void erase | ( | const Key & | key | ) |
Erase all matching keys from the table.
| void erase | ( | iterator | node | ) |
Erase the given entry.
| HashTable< Key, Value >::iterator find | ( | const Key & | key | ) |
Find the first entry for the given key.
| const_iterator find | ( | const Key & | ) | const |
Find the first entry for the given key.
| HashTable< Key, Value >::iterator 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 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 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.
|
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.