GClasses
GClasses::GHashTableBase Class Referenceabstract

Detailed Description

The base class of hash tables.

#include <GHashTable.h>

Inheritance diagram for GClasses::GHashTableBase:
GClasses::GConstStringHashTable GClasses::GConstStringToIndexHashTable GClasses::GHashTable GClasses::GNodeHashTable

Public Member Functions

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 Member Functions

 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)
 
virtual bool areKeysEqual (const char *pKey1, const char *pKey2)=0
 Returns true iff the keys compare equal. More...
 
virtual size_t hash (const char *pKey, size_t nBucketCount)=0
 Returns a hash of the key. More...
 

Protected Attributes

size_t m_nBucketCount
 
size_t m_nCount
 
size_t m_nModCount
 
struct HashBucketm_pBuckets
 
struct HashBucketm_pFirstEmpty
 

Friends

class GHashTableEnumerator
 

Constructor & Destructor Documentation

GClasses::GHashTableBase::GHashTableBase ( size_t  nInitialBucketCount)
protected
virtual GClasses::GHashTableBase::~GHashTableBase ( )
virtual

Member Function Documentation

void GClasses::GHashTableBase::_Add ( const char *  pKey,
const void *  pValue 
)
protected

Adds a key/value pair to the hash table.

size_t GClasses::GHashTableBase::_Count ( const char *  pKey)
protected

Returns the number of values with the specified key.

template<class T >
bool GClasses::GHashTableBase::_Get ( const char *  pKey,
T **  pOutValue 
)
protected

Returns true and the first occurrence of a value with the specified key if one exists.

void GClasses::GHashTableBase::_Remove ( const char *  pKey)
protected

Removes the first found occurrence of the specified key.

void GClasses::GHashTableBase::_Resize ( size_t  nNewSize)
protected
virtual bool GClasses::GHashTableBase::areKeysEqual ( const char *  pKey1,
const char *  pKey2 
)
protectedpure virtual
virtual size_t GClasses::GHashTableBase::hash ( const char *  pKey,
size_t  nBucketCount 
)
protectedpure virtual
size_t GClasses::GHashTableBase::revisionNumber ( )
inline

Returns a number that changes when the contents of this table are modified (This is useful for detecting invalidated iterators)

size_t GClasses::GHashTableBase::size ( )
inline

Returns the number of items in this hash table.

Friends And Related Function Documentation

friend class GHashTableEnumerator
friend

Member Data Documentation

size_t GClasses::GHashTableBase::m_nBucketCount
protected
size_t GClasses::GHashTableBase::m_nCount
protected
size_t GClasses::GHashTableBase::m_nModCount
protected
struct HashBucket* GClasses::GHashTableBase::m_pBuckets
protected
struct HashBucket* GClasses::GHashTableBase::m_pFirstEmpty
protected