![]() |
Public API Reference |
#include <hash.h>
Inheritance diagram for csHash:
Public Methods | |
csHash (int size=257, int grow_rate=64, int max_size=20000) | |
Construct a hash table with an array of the given size, which for optimisation reasons should be a prime number. More... | |
csHash (const csHash< T > &o) | |
Copy constructor. More... | |
void | Put (const K &key, const T &value) |
Add an element to the hash table. More... | |
csArray< T > | GetAll (uint32 key) const |
Get all the elements with the given key, or empty if there are none. More... | |
void | PutFirst (const K &key, const T &value) |
Add an element to the hash table, overwriting if the key already exists. More... | |
const T & | Get (const K &key) const |
Get the first element matching the given key, or 0 if there is none. More... | |
bool | DeleteAll () |
Delete all the elements, returning false if there are none. More... | |
bool | DeleteAll (const K &key) |
Delete all the elements matching the given key. More... | |
bool | Delete (const K &key, const T &value) |
Delete all the elements matching the given key and value. More... | |
int | GetSize () const |
Get the number of elements in the hash. More... | |
Iterator | GetIterator (const K &key) const |
Return an iterator for the hash, to iterate only over the elements with the given key. More... | |
GlobalIterator | GetIterator () const |
Return an iterator for the hash, to iterate over all elements. More... |
Definition at line 61 of file hash.h.
|
Construct a hash table with an array of the given size, which for optimisation reasons should be a prime number. Grow_rate is the rate at which the hash table grows: Size doubles once there are size/grow_rate collisions. It will not grow after it reaches max_size. Here are a few primes: 7, 11, 19, 29, 59, 79, 101, 127, 151, 199, 251, 307, 401, 503, 809, 1009, 1499, 2003, 3001, 5003, 12263, 25247, 36923, 50119, 70951, 90313, 104707. For a bigger list go to http://www.utm.edu/research/primes/ |
|
Copy constructor.
|
|
Delete all the elements matching the given key and value.
|
|
Delete all the elements matching the given key.
|
|
Delete all the elements, returning false if there are none.
|
|
Get the first element matching the given key, or 0 if there is none.
|
|
Get all the elements with the given key, or empty if there are none.
|
|
Return an iterator for the hash, to iterate over all elements. Modifying the hash (except with DeleteNext) while you have open iterators will cause undefined behaviour. |
|
Return an iterator for the hash, to iterate only over the elements with the given key. Modifying the hash (except with DeleteNext) while you have open iterators will cause undefined behaviour. Definition at line 385 of file hash.h. Referenced by csHash< K, T, ReverseKeyHandler >::GetIterator. |
|
Get the number of elements in the hash.
|
|
Add an element to the hash table.
Reimplemented in csHashReversible. Definition at line 147 of file hash.h. Referenced by csHashReversible< csRef< iRenderLoop >, const char *, StringHashKeyHandler, csRefHashKeyHandler< iRenderLoop > >::Put. |
|
Add an element to the hash table, overwriting if the key already exists.
|