vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Hash< TKey, TValue > Class Template Reference

Hash class (not thread-safe) More...

#include <vrpn_HashST.h>

Public Member Functions

 vrpn_Hash (int init=16)
 constructor More...
 
 vrpn_Hash (unsigned int(*func)(const TKey &key), int init=16)
 constructor More...
 
virtual ~vrpn_Hash ()
 destructor More...
 
void Clear ()
 clears the Hash More...
 
unsigned int GetNrItems () const
 returns the number of items in the Hash More...
 
TValue & Find (const TKey &key)
 returns the value that belongs to this key More...
 
const TValue & Find (const TKey &key) const
 returns the value that belongs to this key More...
 
bool IsPresent (const TValue &value, TKey &key) const
 checks if the Hash contains a value and returns its key More...
 
bool MoveFirst () const
 moves an iterator to the first element and returns false if no element is present More...
 
bool MoveNext () const
 moves the iterator to the next element and returns false if no more element is present More...
 
TValue GetCurrentValue () const
 returns the value of the current item More...
 
TKey GetCurrentKey () const
 returns the key of the current item More...
 
void SetCurrentValue (TValue theValue)
 sets the Value of the current key More...
 
bool GetCurrentKeyAndValue (TKey &theKey, TValue &theValue) const
 returns the key and the value of the current item More...
 
bool Add (TKey key, TValue value)
 adds a new (key, value) pair, returns true if succeeded More...
 
bool Remove (TKey key)
 removes the value that belongs to this key, returns true if succeeded More...
 

Detailed Description

template<class TKey, class TValue>
class vrpn_Hash< TKey, TValue >

Hash class (not thread-safe)

This class implements a NON thread-safe template Hash. Both the key as the value are templates. It is possible to iterate over this Hash, but no guarantee is given about the order in which the items are returned. All keys must be unique.

Attention
In order to use the find function, the value template must support a cast from 0.
Author
Joan De Boeck
Chris Raymaekers

Definition at line 31 of file vrpn_HashST.h.

Constructor & Destructor Documentation

◆ vrpn_Hash() [1/2]

template<class TKey , class TValue >
vrpn_Hash< TKey, TValue >::vrpn_Hash ( int  init = 16)

constructor

Constructs a new Hash.

Parameters
initHash's initial size and grow size

Definition at line 97 of file vrpn_HashST.h.

◆ vrpn_Hash() [2/2]

template<class TKey, class TValue >
vrpn_Hash< TKey, TValue >::vrpn_Hash ( unsigned int(*)(const TKey &key)  func,
int  init = 16 
)

constructor

Constructs a new Hash.

Parameters
functhe function that used to calculate Hash values from the keys
initHash's initial size and grow size

Definition at line 115 of file vrpn_HashST.h.

◆ ~vrpn_Hash()

template<class TKey , class TValue >
vrpn_Hash< TKey, TValue >::~vrpn_Hash ( )
virtual

destructor

Definition at line 128 of file vrpn_HashST.h.

Member Function Documentation

◆ Add()

template<class TKey, class TValue>
bool vrpn_Hash< TKey, TValue >::Add ( TKey  key,
TValue  value 
)

adds a new (key, value) pair, returns true if succeeded

Definition at line 201 of file vrpn_HashST.h.

◆ Clear()

template<class TKey , class TValue >
void vrpn_Hash< TKey, TValue >::Clear ( )

clears the Hash

Definition at line 136 of file vrpn_HashST.h.

◆ Find() [1/2]

template<class TKey, class TValue >
TValue & vrpn_Hash< TKey, TValue >::Find ( const TKey &  key)

returns the value that belongs to this key

Definition at line 151 of file vrpn_HashST.h.

◆ Find() [2/2]

template<class TKey, class TValue >
const TValue & vrpn_Hash< TKey, TValue >::Find ( const TKey &  key) const

returns the value that belongs to this key

Definition at line 168 of file vrpn_HashST.h.

◆ GetCurrentKey()

template<class TKey , class TValue >
TKey vrpn_Hash< TKey, TValue >::GetCurrentKey ( ) const

returns the key of the current item

Definition at line 306 of file vrpn_HashST.h.

◆ GetCurrentKeyAndValue()

template<class TKey, class TValue>
bool vrpn_Hash< TKey, TValue >::GetCurrentKeyAndValue ( TKey &  theKey,
TValue &  theValue 
) const

returns the key and the value of the current item

Definition at line 316 of file vrpn_HashST.h.

◆ GetCurrentValue()

template<class TKey , class TValue >
TValue vrpn_Hash< TKey, TValue >::GetCurrentValue ( ) const

returns the value of the current item

Definition at line 290 of file vrpn_HashST.h.

◆ GetNrItems()

template<class TKey, class TValue>
unsigned int vrpn_Hash< TKey, TValue >::GetNrItems ( ) const
inline

returns the number of items in the Hash

Definition at line 44 of file vrpn_HashST.h.

◆ IsPresent()

template<class TKey, class TValue>
bool vrpn_Hash< TKey, TValue >::IsPresent ( const TValue &  value,
TKey &  key 
) const

checks if the Hash contains a value and returns its key

Definition at line 182 of file vrpn_HashST.h.

◆ MoveFirst()

template<class TKey , class TValue >
bool vrpn_Hash< TKey, TValue >::MoveFirst ( ) const

moves an iterator to the first element and returns false if no element is present

Definition at line 272 of file vrpn_HashST.h.

◆ MoveNext()

template<class TKey , class TValue >
bool vrpn_Hash< TKey, TValue >::MoveNext ( ) const

moves the iterator to the next element and returns false if no more element is present

Definition at line 280 of file vrpn_HashST.h.

◆ Remove()

template<class TKey, class TValue >
bool vrpn_Hash< TKey, TValue >::Remove ( TKey  key)

removes the value that belongs to this key, returns true if succeeded

Definition at line 243 of file vrpn_HashST.h.

◆ SetCurrentValue()

template<class TKey , class TValue>
void vrpn_Hash< TKey, TValue >::SetCurrentValue ( TValue  theValue)

sets the Value of the current key

Definition at line 299 of file vrpn_HashST.h.


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