C4 Engine Terathon Software C4 Engine API Documentation

• Utility Library

API Links
Developer Links

class HashTable

Defined in:  C4Hash.h
The HashTable class encapsulates a dynamically resizable hash table.
Definition

template <class type> class HashTable : public HashTableBase

Member Functions
HashTable::GetElementCount Returns the number of elements in a hash table.
HashTable::Insert Inserts an element into a hash table.
HashTable::Remove Removes a particular element from a hash table.
HashTable::RemoveAll Removes all elements from a hash table.
HashTable::Purge Deletes all elements in a hash table.
HashTable::Find Finds an element in a hash table.
Template Parameters
type The type of the class that can be stored in the hash table. The class specified by this parameter should inherit directly from the HashTableElement class using the same template parameter.
Constructor

HashTable();

Description
The HashTable class template is a container used to organize a homogenous set of objects. The class type of objects that are to be stored in the hash table must be a subclass of the HashTableElement class template using the same template parameter as the HashTable container. A particular object can be a member of only one hash table at a time.

Upon construction, a HashTable object is empty. When a HashTable object is destroyed, all of the members of the hash table are also destroyed. To avoid deleting the members of a hash table when a HashTable object is destroyed, first call the HashTable::RemoveAll function to remove all of the hash table's members.

The class specified by the type template parameter must define a type named KeyType and a function named GetKey that has one of the following two prototypes.

KeyType GetKey(voidconst;

const KeyType& GetKey(voidconst;

static unsigned_int32 Hash(KeyType key);

static unsigned_int32 Hash(const KeyType& key);

Base Classes
HashTableBase Used internally to encapsulate common functionality that is independent of the template parameter.
See Also

HashTableElement