GClasses
GClasses::GConstStringHashTable Class Reference

Detailed Description

Hash table based on keys of constant strings (or at least strings that won't change during the lifetime of the hash table). It's a good idea to use a GHeap in connection with this class.

#include <GHashTable.h>

Inheritance diagram for GClasses::GConstStringHashTable:
GClasses::GHashTableBase

Public Member Functions

 GConstStringHashTable (size_t nInitialBucketCount, bool bCaseSensitive)
 
virtual ~GConstStringHashTable ()
 
void add (const char *pKey, const void *pValue)
 Adds a key and value pair to the hash table. The key should be a constant string (or at least a string that won't change over the lifetime of the hash table). The GHeap class provides a good place to store such a string. More...
 
virtual bool areKeysEqual (const char *pKey1, const char *pKey2)
 Returns true iff the two keys are equal. More...
 
template<class T >
bool get (const char *pKey, T **ppOutValue)
 Gets the value for the specified key. More...
 
bool get (const char *pKey, size_t nLen, void **ppOutValue)
 Gets the value for the specified key. More...
 
virtual size_t hash (const char *pKey, size_t nBucketCount)
 Computes a hash of the key. More...
 
void remove (const char *pKey)
 Removes an entry from the hash table. More...
 
- Public Member Functions inherited from GClasses::GHashTableBase
virtual ~GHashTableBase ()
 
size_t revisionNumber ()
 Returns a number that changes when the contents of this table are modified (This is useful for detecting invalidated iterators) More...
 
size_t size ()
 Returns the number of items in this hash table. More...
 

Protected Attributes

bool m_bCaseSensitive
 
- Protected Attributes inherited from GClasses::GHashTableBase
size_t m_nBucketCount
 
size_t m_nCount
 
size_t m_nModCount
 
struct HashBucketm_pBuckets
 
struct HashBucketm_pFirstEmpty
 

Additional Inherited Members

- Protected Member Functions inherited from GClasses::GHashTableBase
 GHashTableBase (size_t nInitialBucketCount)
 
void _Add (const char *pKey, const void *pValue)
 Adds a key/value pair to the hash table. More...
 
size_t _Count (const char *pKey)
 Returns the number of values with the specified key. More...
 
template<class T >
bool _Get (const char *pKey, T **pOutValue)
 Returns true and the first occurrence of a value with the specified key if one exists. More...
 
void _Remove (const char *pKey)
 Removes the first found occurrence of the specified key. More...
 
void _Resize (size_t nNewSize)
 

Constructor & Destructor Documentation

GClasses::GConstStringHashTable::GConstStringHashTable ( size_t  nInitialBucketCount,
bool  bCaseSensitive 
)
inline
virtual GClasses::GConstStringHashTable::~GConstStringHashTable ( )
inlinevirtual

Member Function Documentation

void GClasses::GConstStringHashTable::add ( const char *  pKey,
const void *  pValue 
)
inline

Adds a key and value pair to the hash table. The key should be a constant string (or at least a string that won't change over the lifetime of the hash table). The GHeap class provides a good place to store such a string.

virtual bool GClasses::GConstStringHashTable::areKeysEqual ( const char *  pKey1,
const char *  pKey2 
)
inlinevirtual

Returns true iff the two keys are equal.

Implements GClasses::GHashTableBase.

template<class T >
bool GClasses::GConstStringHashTable::get ( const char *  pKey,
T **  ppOutValue 
)
inline

Gets the value for the specified key.

bool GClasses::GConstStringHashTable::get ( const char *  pKey,
size_t  nLen,
void **  ppOutValue 
)

Gets the value for the specified key.

virtual size_t GClasses::GConstStringHashTable::hash ( const char *  pKey,
size_t  nBucketCount 
)
inlinevirtual

Computes a hash of the key.

Implements GClasses::GHashTableBase.

void GClasses::GConstStringHashTable::remove ( const char *  pKey)
inline

Removes an entry from the hash table.

Member Data Documentation

bool GClasses::GConstStringHashTable::m_bCaseSensitive
protected