UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HashTable Class Reference

HashTable. More...

#include <hashtable.h>

Public Types

enum  HashType { Rotating = 0 }
 Description of the Enumeration HashType. More...
 

Public Member Functions

 HashTable (int iSize=1000003)
 Constructor of the hash table. More...
 
 ~HashTable ()
 The destructor cleans up its resources. More...
 
void add (const UaNodeId &key, ChainEntry *pValue)
 Adds a new ChainEntry object with a corresponding key. More...
 
ChainEntrylookup (const UaNodeId &key)
 Looks up the value object identified by the passed string. More...
 
ChainEntryremove (const UaNodeId &key)
 Removes an object from the hash table identified by the passed string. More...
 
void setHashType (HashType type)
 Sets the HashType. More...
 
void clear (bool bDelete=true)
 Clears the hash table. More...
 
int count ()
 Get the number of elements in the hash table. More...
 
int tableSize () const
 Get the size the table was initialized with. More...
 

Protected Member Functions

int hash (const unsigned char *pData, unsigned int iLen)
 Create a new Hash with specified length and data. More...
 
int rotating_hash (const unsigned char *pData, unsigned int iLen)
 Rotating hash. More...
 
HashIterator next (const HashIterator *pCurrent)
 Get next element from table starting at iterator.
 

Detailed Description

HashTable.

This class implements a fast hash table. 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

Member Enumeration Documentation

Description of the Enumeration HashType.

Enumerator
Rotating 

value 1

Constructor & Destructor Documentation

HashTable::HashTable ( int  iSize = 1000003)

Constructor of the hash table.

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 performance is decreasing.

Parameters
iSizemax number of entries. You should choose a prime here to reduce collisions.
HashTable::~HashTable ( )

The destructor 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 corresponding 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 hash table.

Parameters
bDeletetrue if everything is cleared false if not.
int HashTable::count ( )

Get the number of elements in the hash table.

Returns
the number of elements currently filled ein the hash table.
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 hash table identified by the passed string.

Parameters
keythe key to search 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).
int HashTable::tableSize ( ) const

Get the size the table was initialized with.

Returns
the internal size of the hashtable.

The documentation for this class was generated from the following files: