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:
iSizemax 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:
keya unicode string
pValuethe value to store
void HashTable::clear ( bool  bDelete = true )

Clears the Hashtable.

Parameters:
bDeletetrue 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:
pDatathe data to put into the hash.
iLenthe length of the Hash.
Returns:
the created Hash.
ChainEntry * HashTable::lookup ( const UaNodeId key )

Looks up the value object identified by the passed string.

Parameters:
keythe 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:
keythe key to seach for
Returns:
the removed object or NULL if not found
int HashTable::rotating_hash ( const unsigned char *  pData,
unsigned int  iLen 
) [protected]

Rotating hash

Parameters:
pDatathe data to put into the hash.
iLenthe length of the Hash.
Returns:
the created rotating_hash.
void HashTable::setHashType ( HashType  type )

Sets the HashType.

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

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