Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

HashTableKey_Int Class Reference
[Containers]

Hash table key implementation for integer keys. More...

Inheritance diagram for HashTableKey_Int:

HashTableKey

List of all members.


Public Member Functions

 HashTableKey_Int ()
 HashTableKey_Int (unsigned int number)
virtual StringId GetType () const
virtual unsigned int GetHash () const
bool Compare (const HashTableKey *key) const
unsigned int GetInt () const

Detailed Description

Hash table key implementation for integer keys.

Author:
Mattias Gustavsson
Hash table key implementation for integer keys. This is the simplest form of hash key, and it uses the number passed in as hash value, so for some scenarios the calling code might need to transform the value in some way to make it a suitable hashing value. For example, this key type will work for using object pointers as hash keys, by just casting the pointer to an int. However, since objects are aligned on 4 byte boundaries, we waste 3 out of 4 hash entries. If the value was divided by 4 before being passed to HashTableKey_Int, we wouldn't have that problem. This hash key type is provided as a means to store things based on any kind of hashing value. If specific behavior is wanted, it is good to implement a specific hashtable key type for that type of key. For example, there could be a HashTableKey_Pointer, that would automatically do the divide by 4, as explained above, or do some even more clever tricks, such as manipulating the bits of the value, to get a more suitable hash value.

Definition at line 34 of file HashTableKey_Int.h.


Constructor & Destructor Documentation

HashTableKey_Int::HashTableKey_Int (  ) 

Definition at line 8 of file HashTableKey_Int.cpp.

HashTableKey_Int::HashTableKey_Int ( unsigned int  number  ) 

Constructor

Parameters:
number The actual number to be used for this key

Definition at line 16 of file HashTableKey_Int.cpp.


Member Function Documentation

StringId HashTableKey_Int::GetType (  )  const [virtual]

Used to find out the specific type of HashTableKey that this class implements

Returns:
A string id ("HashTableKey_Int") uniquely identifying this key type

Implements HashTableKey.

Definition at line 57 of file HashTableKey_Int.cpp.

unsigned int HashTableKey_Int::GetHash (  )  const [virtual]

Gets the hash number for this key

Returns:
The hash number for this key

Implements HashTableKey.

Definition at line 25 of file HashTableKey_Int.cpp.

bool HashTableKey_Int::Compare ( const HashTableKey key  )  const [virtual]

Compares this key with the specified key.

Returns:
True if the two keys are identical, false if they are not

Implements HashTableKey.

Definition at line 41 of file HashTableKey_Int.cpp.

unsigned int HashTableKey_Int::GetInt (  )  const

Gets the actual number used for this key

Returns:
The number used for this key

Definition at line 33 of file HashTableKey_Int.cpp.



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.