GClasses

GClasses::GHashTableBase Class Reference

The base class of hash tables. More...

#include <GHashTable.h>

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

List of all members.

Public Member Functions

virtual ~GHashTableBase ()
size_t size ()
 Returns the number of items in this hash table.
size_t revisionNumber ()
 Returns a number that changes when the contents of this table are modified (This is useful for detecting invalidated iterators)

Protected Member Functions

 GHashTableBase (size_t nInitialBucketCount)
virtual size_t hash (const char *pKey, size_t nBucketCount)=0
 Returns a hash of the key.
virtual bool areKeysEqual (const char *pKey1, const char *pKey2)=0
 Returns true iff the keys compare equal.
void _Resize (size_t nNewSize)
void _Add (const char *pKey, const void *pValue)
 Adds a key/value pair to the hash table.
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.
void _Remove (const char *pKey)
 Removes the first found occurrence of the specified key.
size_t _Count (const char *pKey)
 Returns the number of values with the specified key.

Protected Attributes

struct HashBucketm_pBuckets
struct HashBucketm_pFirstEmpty
size_t m_nBucketCount
size_t m_nCount
size_t m_nModCount

Friends

class GHashTableEnumerator

Detailed Description

The base class of hash tables.


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 
) [protected, pure virtual]
virtual size_t GClasses::GHashTableBase::hash ( const char *  pKey,
size_t  nBucketCount 
) [protected, pure 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