GClasses

GClasses::GHashTable Class Reference

Implements a typical hash table. (It doesn't take ownership of the objects you add, so you must still delete them yourself.) More...

#include <GHashTable.h>

Inheritance diagram for GClasses::GHashTable:
GClasses::GHashTableBase

List of all members.

Public Member Functions

 GHashTable (size_t nInitialBucketCount)
virtual ~GHashTable ()
virtual size_t hash (const char *pKey, size_t nBucketCount)
 Computes a hash of the key.
virtual bool areKeysEqual (const char *pKey1, const char *pKey2)
 Returns true iff the two keys are equal.
void add (const void *pKey, const void *pValue)
 Adds a pointer key and value pair to the hash table. The key can not be NULL.
bool get (const void *pKey, void **ppOutValue)
 Gets a value based on the key.
void remove (const void *pKey)
 Removes an entry from the hash table.

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure.

Detailed Description

Implements a typical hash table. (It doesn't take ownership of the objects you add, so you must still delete them yourself.)


Constructor & Destructor Documentation

GClasses::GHashTable::GHashTable ( size_t  nInitialBucketCount) [inline]
virtual GClasses::GHashTable::~GHashTable ( ) [inline, virtual]

Member Function Documentation

void GClasses::GHashTable::add ( const void *  pKey,
const void *  pValue 
) [inline]

Adds a pointer key and value pair to the hash table. The key can not be NULL.

virtual bool GClasses::GHashTable::areKeysEqual ( const char *  pKey1,
const char *  pKey2 
) [inline, virtual]

Returns true iff the two keys are equal.

Implements GClasses::GHashTableBase.

bool GClasses::GHashTable::get ( const void *  pKey,
void **  ppOutValue 
) [inline]

Gets a value based on the key.

virtual size_t GClasses::GHashTable::hash ( const char *  pKey,
size_t  nBucketCount 
) [inline, virtual]

Computes a hash of the key.

Implements GClasses::GHashTableBase.

void GClasses::GHashTable::remove ( const void *  pKey) [inline]

Removes an entry from the hash table.

static void GClasses::GHashTable::test ( ) [static]

Performs unit tests for this class. Throws an exception if there is a failure.