Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

HashTable< HASHTABLEKEY, TYPE > Class Template Reference
[Containers]

Stores data in a hash table, indexed by any type of key. More...

List of all members.


Classes

struct  HashTableItem
 HashTableItem.

Public Member Functions

 HashTable (int initialSlots=64)
 ~HashTable ()
void Insert (const HASHTABLEKEY &key, const TYPE &data)
void Remove (const HASHTABLEKEY &key)
void Remove (const HashTableIterator< HASHTABLEKEY, TYPE > &iterator)
int GetItemCount () const
void Clear (bool releaseMemory=false)

Friends

class HashTableIterator< HASHTABLEKEY, TYPE >
 It makes sense to have iterators being friends with the class they are iterating.

Detailed Description

template<class HASHTABLEKEY, class TYPE>
class HashTable< HASHTABLEKEY, TYPE >

Stores data in a hash table, indexed by any type of key.

Author:
Mattias Gustavsson
A hash table store items associated with a key, in such a way that you can quickly retrieve a value from the key. Internally, the hash table stores the items in an array, and from the key it calculates a number (called a hash value), which is used to find which array entry to place the item in. This means there's no looping through the array when finding an item, as the hash value is used to go straight into the right array entry.

Definition at line 25 of file HashTable.h.


Constructor & Destructor Documentation

template<class HASHTABLEKEY , class TYPE >
HashTable< HASHTABLEKEY, TYPE >::HashTable ( int  initialSlots = 64  ) 

Constructor

Parameters:
initialSlots Number of slots initially in the table. Will grow when table is full.

Definition at line 9 of file HashTable.inl.

template<class HASHTABLEKEY , class TYPE >
HashTable< HASHTABLEKEY, TYPE >::~HashTable (  ) 

Destructor

Definition at line 36 of file HashTable.inl.


Member Function Documentation

template<class HASHTABLEKEY, class TYPE>
void HashTable< HASHTABLEKEY, TYPE >::Insert ( const HASHTABLEKEY &  key,
const TYPE &  data 
)

Insert an item into the table, associating it with the specified key.

Parameters:
key Key to be used when searching the table for this item
data Item to be added.

Definition at line 49 of file HashTable.inl.

template<class HASHTABLEKEY, class TYPE >
void HashTable< HASHTABLEKEY, TYPE >::Remove ( const HASHTABLEKEY &  key  ) 

Removes the item with the specified key from the table.

Parameters:
key Key of the item to be removed

Definition at line 155 of file HashTable.inl.

template<class HASHTABLEKEY, class TYPE>
void HashTable< HASHTABLEKEY, TYPE >::Remove ( const HashTableIterator< HASHTABLEKEY, TYPE > &  iterator  ) 

Removes an in

Parameters:
iterator item to remove

Definition at line 135 of file HashTable.inl.

template<class HASHTABLEKEY , class TYPE >
int HashTable< HASHTABLEKEY, TYPE >::GetItemCount (  )  const

Retrieves the total number of items currently in the table

Returns:
Number of items in the table.

Definition at line 206 of file HashTable.inl.

template<class HASHTABLEKEY , class TYPE >
void HashTable< HASHTABLEKEY, TYPE >::Clear ( bool  releaseMemory = false  ) 

Removes all entries from the table. It is up to the application to destroy the objects that are contained in the table.

Parameters:
releaseMemory If set to true, all memory used by the table will be released, and the maximum number of items that can be stored is reset to the initial value

Definition at line 215 of file HashTable.inl.


Friends And Related Function Documentation

template<class HASHTABLEKEY, class TYPE>
friend class HashTableIterator< HASHTABLEKEY, TYPE > [friend]

It makes sense to have iterators being friends with the class they are iterating.

Definition at line 82 of file HashTable.h.



Pixie University and the Pixie Game Engine is created and managed by Mattias Gustavsson.
Reproduction/republishing of any material on this site without permission is strictly prohibited.