FastPointerHashTable< T > Class Template Reference

A HashTable for pointers only. <hash table="" with="" no="" collision="" handling="">. More...

#include <FastPointerHashTable.hpp>

List of all members.


Public Member Functions

 FastPointerHashTable (unsigned int siz)
void put (T &elem, unsigned int key)
 Insert an element which must be NOT EQUAL to NULL.
T & get (unsigned int key)
 returns a reference to the element stored in the Table.
void freeElement (const unsigned int key)
void freeAllElements ()
void unlinkElement (const unsigned int key)

Detailed Description

template<class T>
class FastPointerHashTable< T >

A HashTable for pointers only. <hash table="" with="" no="" collision="" handling="">.

Hashing is done with a simple MODULO operation. If a collision occurs, the element previously stored at that position is DELETED and the new element is inserted.

Author:
Peter Schojer
Version:
Id
FastPointerHashTable.hpp,v 1.6 2006/01/20 15:37:17 mkropfbe Exp

Definition at line 60 of file FastPointerHashTable.hpp.


Member Function Documentation

template<class T>
T& FastPointerHashTable< T >::get unsigned int  key  )  [inline]
 

returns a reference to the element stored in the Table.

Manipulating this reference, will thus also update the element in the Table. If you delete the element outside, you MUST call unlinkElement prior.Definition at line 105 of file FastPointerHashTable.hpp.

00105 { 00106 unsigned int pos=key%size; 00107 if(keys[pos]==key) 00108 return data[pos]; 00109 return invalid; 00110 };

template<class T>
void FastPointerHashTable< T >::put T &  elem,
unsigned int  key
[inline]
 

Insert an element which must be NOT EQUAL to NULL.

NULL elements will be ignored. If a collission is detected no overflow handling happens. The old element is deleted and the new one inserted. Definition at line 88 of file FastPointerHashTable.hpp.

00088 { 00089 unsigned int pos=key%size; 00090 assert(elem != NULL); 00091 if(elem==NULL) 00092 return; 00093 // if we receive another element that maps to the same pos but has 00094 // a different key then we delete it! 00095 if(data[pos]) 00096 delete data[pos]; 00097 data[pos]=elem; 00098 keys[pos]=key; 00099 };


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