#include <hashtable.h>
Inheritance diagram for HashTable:
Public Methods | |
HashTable (void) | |
A constructor. | |
virtual | ~HashTable (void) |
A destructor. More... | |
virtual T_ * | find (Key_ key) |
Find an item by given key. More... | |
virtual void | insert (Key_ key, T_ *item) |
Insert an item with gven key and data. More... | |
virtual bool | remove (Key_ key) |
Remove an item with given key. More... | |
virtual bool | contains (Key_ key) |
Test whether hash array contains an item with given key. More... | |
virtual void | clear (void) |
Clear the hash array. More... | |
virtual void | setAutoDelete (bool ad) |
Protected Attributes | |
HashTableBucket< Key_, T_, HashTableBucketContainer_ > ** | table_ |
An array of buckets. | |
HashTableHash< size_ > | hash_ |
Hash structure. |
Hash array is implemented as an array (with given size_) of buckets. Buckets are represented by BucketContainer_ and hold data of type T_ which are accessible by keys of type Key_. For best performance, the size_ should be a suitably large prime number.
List of some useful prime numbers:
53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653, 100663319, 201326611, 402653189, 805306457, 1610612741, 3221225473, 4294967291
Key_ | Class representing the type of a key. |
T_ | Class representing the type of data. |
BucketContainer_ | Template class representing container for buckets. |
size_ | Size of the hash array. |
Definition at line 262 of file hashtable.h.
|
A destructor.
Clears the contents of the hash array. Definition at line 282 of file hashtable.h. |
|
Clear the hash array.
Removes all items from the hash array. The data of the items aren't removed unless setAutoDelete is called. Implements Collection. Definition at line 393 of file hashtable.h. Referenced by HashTable< XmlChar *, unsigned long, List, 3079 >::~HashTable. |
|
Test whether hash array contains an item with given key.
Definition at line 377 of file hashtable.h. Referenced by HashTable< XmlChar *, unsigned long, List, 3079 >::insert. |
|
Find an item by given key.
This function finds an item by given key.
Definition at line 298 of file hashtable.h. |
|
Insert an item with gven key and data.
This function inserts new item into the hash array using appropriate hash function.
Definition at line 317 of file hashtable.h. |
|
Remove an item with given key.
Data of the item is not deleted unless setAutoDelete was changed.
Definition at line 350 of file hashtable.h. |
|
Turn on/off auto deletion of item data. If auto deletion is turned off (the default), removing an item doesn't delete the data of the item. If auto deletion is turned odn, the data is deleted together with the item.
Reimplemented from Collection. Definition at line 424 of file hashtable.h. |