Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate > Class Template Reference

Abstract general hash table. More...

#include <tables.h>

List of all members.

Public Member Functions

void disableRehash ()
 Control rehashing: by default hash tables rehash themselves automatically.
void enableRehash ()
uint32_t getHashMask () const
 Return the hash mask to get access to the table: index = hashValue & mask.
size_t getNbBuckets () const
size_t getTableSize () const
void reset ()
 Reset the table without deleting the buckets.
void resetDelete ()
 Reset the table and delete the buckets.
base::Enumerator< BucketType > getEnumerator () const
 Enumerator.
void incBuckets ()
 Increase the counter of the buckets.
void decBuckets ()
 Decrease the counter of the buckets.
BucketType ** getAtBucket (uint32_t hashValue) const
 Access to a particular table entry with a hash value.
BucketType * getBucket (uint32_t hashValue) const
 Access to the first bucket in the table with a given hash value.

Protected Types

enum  { MAX_TABLE_SIZE = (1 << 26) }
 We give a limit to the size of the tables to stop rehashing after a certain point. More...

Protected Member Functions

BucketType ** getBuckets () const
 Access to the bucket table.
 AbstractTable (uint32_t sizePower2, bool aggressive)
 Protected constructor: this is an abstract class only.
 ~AbstractTable ()
 Destructor: not virtual.

Protected Attributes

size_t nbBuckets
 number of buckets

Private Member Functions

bool needsRehash () const

Private Attributes

uint32_t mask
 mask to apply to hash value to get indices = size - 1 since the size of the table is a power of 2
uint32_t shiftThreshold
 mask >> shiftThreshold is the threshold
bool mayRehash
 used to disable rehashing
BucketType ** buckets
 the table of buckets

Classes

struct  Bucket_t
 Simple adapter to tie together the hash table and bucket types. More...


Detailed Description

template<class BucketType, class BucketParentType, class BucketParentTemplate>
class hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >

Abstract general hash table.

DO NOT USE DIRECTLY.

Parameters:
BucketType,: customized buckets (with customized data) to use.
BucketParentType,: SingleBucket_t or DoubleBucket_t
BucketParentTemplate,: SingleBucket or DoubleBucket


Member Enumeration Documentation

template<class BucketType, class BucketParentType, class BucketParentTemplate>
anonymous enum [protected]
 

We give a limit to the size of the tables to stop rehashing after a certain point.

Enumeration values:
MAX_TABLE_SIZE 


Constructor & Destructor Documentation

template<class BucketType, class BucketParentType, class BucketParentTemplate>
hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::AbstractTable uint32_t  sizePower2,
bool  aggressive
[inline, protected]
 

Protected constructor: this is an abstract class only.

Parameters:
sizePower2,: size in power of 2, ie, real size will be 2**sizePower2.
aggressive,: aggressive rehashing or not, which decides the threshold for rehashing.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::~AbstractTable  )  [inline, protected]
 

Destructor: not virtual.

There is no polymorphism involved here.


Member Function Documentation

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::decBuckets  )  [inline]
 

Decrease the counter of the buckets.

Call this whenever you remove a bucket from the hash table.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::disableRehash  )  [inline]
 

Control rehashing: by default hash tables rehash themselves automatically.

You can disable this feature.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::enableRehash  )  [inline]
 

template<class BucketType, class BucketParentType, class BucketParentTemplate>
BucketType** hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getAtBucket uint32_t  hashValue  )  const [inline]
 

Access to a particular table entry with a hash value.

Parameters:
hashValue,: the hash to compute the index.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
BucketType* hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getBucket uint32_t  hashValue  )  const [inline]
 

Access to the first bucket in the table with a given hash value.

Parameters:
hashValue,: the hash to compute the index.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
BucketType** hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getBuckets  )  const [inline, protected]
 

Access to the bucket table.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
base::Enumerator<BucketType> hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getEnumerator  )  const [inline]
 

Enumerator.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
uint32_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getHashMask  )  const [inline]
 

Return the hash mask to get access to the table: index = hashValue & mask.

Returns:
a binary mask.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
size_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getNbBuckets  )  const [inline]
 

Returns:
the number of used buckets so far.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
size_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::getTableSize  )  const [inline]
 

Returns:
the size of the table. As the size is a power of 2, mask = size - 1. We keep mask because it is more useful.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::incBuckets  )  [inline]
 

Increase the counter of the buckets.

This automatically calls rehash if needed. Call this whenever you add a new bucket in the hash table, BUT ALWAYS AFTER adding a bucket (bucket->link(somewhere) because of the rehashing.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
bool hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::needsRehash  )  const [inline, private]
 

Returns:
true if the threshold for rehashing is reached

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::reset  )  [inline]
 

Reset the table without deleting the buckets.

template<class BucketType, class BucketParentType, class BucketParentTemplate>
void hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::resetDelete  )  [inline]
 

Reset the table and delete the buckets.

Note: as the bucket type is custom, the delete call may call destructors of the sub-types.


Member Data Documentation

template<class BucketType, class BucketParentType, class BucketParentTemplate>
BucketType** hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::buckets [private]
 

the table of buckets

template<class BucketType, class BucketParentType, class BucketParentTemplate>
uint32_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::mask [private]
 

mask to apply to hash value to get indices = size - 1 since the size of the table is a power of 2

template<class BucketType, class BucketParentType, class BucketParentTemplate>
bool hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::mayRehash [private]
 

used to disable rehashing

template<class BucketType, class BucketParentType, class BucketParentTemplate>
size_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::nbBuckets [protected]
 

number of buckets

template<class BucketType, class BucketParentType, class BucketParentTemplate>
uint32_t hash::AbstractTable< BucketType, BucketParentType, BucketParentTemplate >::shiftThreshold [private]
 

mask >> shiftThreshold is the threshold


The documentation for this class was generated from the following file:
Generated on Fri Jun 30 00:03:00 2006 for Module hash by  doxygen 1.4.2