HashTable Class Reference

This class implements a fast hashtable. primes for special tables sizes: size 1.000, 10.000, 100.000, 1.000.000, 10.000.000 prime 1.009, 10.007, 100.003, 1.000.003, 10.000.019. More...

#include <hashtable.h>

Collaboration diagram for HashTable:

List of all members.


Public Types

enum  HashType { Rotating = 0 }

Public Member Functions

 HashTable (int iSize=1000003)
 ~HashTable ()
void add (const UaNodeId &key, ChainEntry *pValue)
ChainEntrylookup (const UaNodeId &key)
ChainEntryremove (const UaNodeId &key)
void setHashType (HashType type)
void clear (bool bDelete=true)

Protected Member Functions

int hash (const unsigned char *pData, unsigned int iLen)
int rotating_hash (const unsigned char *pData, unsigned int iLen)

Detailed Description

This class implements a fast hashtable. primes for special tables sizes: size 1.000, 10.000, 100.000, 1.000.000, 10.000.000 prime 1.009, 10.007, 100.003, 1.000.003, 10.000.019.

HashTable


Member Enumeration Documentation

Description of the Enumeration HashType

Enumerator:
Rotating  value 1


Constructor & Destructor Documentation

HashTable::HashTable ( int  iSize = 1000003  ) 

Constructor of the hashtable. You can initialize the max size of the table. You can fill in even more the max elements, but then there must be collision and perfomance is decreasing.

Parameters:
iSize max number of entries. You should choose a prime here to reduce collisions.

HashTable::~HashTable (  ) 

The descructor cleans up its resources. It does not delete the referenced objects.


Member Function Documentation

void HashTable::add ( const UaNodeId key,
ChainEntry pValue 
)

Adds a new ChainEntry object with a correspondig key. You can use this key to lookup the object.

Parameters:
key a unicode string
pValue the value to store

ChainEntry * HashTable::lookup ( const UaNodeId key  ) 

Looks up the value object identified by the passed string.

Parameters:
key the key to search for
Returns:
the found object or NULL if not found

ChainEntry * HashTable::remove ( const UaNodeId key  ) 

Removes an object from the hashtable identified by the passed string.

Parameters:
key the key to seach for
Returns:
the removed object or NULL if not found

void HashTable::setHashType ( HashType  type  ) 

Sets the HashType.

Parameters:
type a Variable filled with the HashType (e.g. rotating_hash).

void HashTable::clear ( bool  bDelete = true  ) 

Clears the Hashtable.

Parameters:
bDelete true if everything is cleared false if not.

int HashTable::hash ( const unsigned char *  pData,
unsigned int  iLen 
) [protected]

Create a new Hash with specified length and data.

Parameters:
pData the data to put into the hash.
iLen the length of the Hash.
Returns:
the created Hash.

int HashTable::rotating_hash ( const unsigned char *  pData,
unsigned int  iLen 
) [protected]

Rotating hash

Parameters:
pData the data to put into the hash.
iLen the length of the Hash.
Returns:
the created rotating_hash.


The documentation for this class was generated from the following files:
  • src/uaserver/uaservercpp/coremodule/hashtable.h
  • src/uaserver/uaservercpp/coremodule/hashtable.cpp