CrystalSpace

Public API Reference

csHashReversible< T, K > Class Template Reference
[Containers]

A csHash<> that maintains a reverse hash for indexing keys by values. More...

#include <csutil/hashr.h>

Inheritance diagram for csHashReversible< T, K >:

List of all members.

Public Member Functions

 csHashReversible (int size=23, int grow_rate=5, int max_size=20000)
 Construct a hash table with an array of the given size, which for optimisation reasons should be a prime number.
bool Delete (const K &key, const T &value)
 Delete all the elements matching the given key and value.
bool DeleteAll (const K &key)
 Delete all the elements matching the given key.
void DeleteAll ()
 Delete all the elements.
const K & GetKey (const T &key, const K &fallback) const
 Get the first key matching the given value, or fallback if there is none.
const K * GetKeyPointer (const T &key) const
 Get a pointer to the first key matching the given value, or 0 if there is none.
void Put (const K &key, const T &value)
 Add an element to the hash and reverse table.
void PutUnique (const K &key, const T &value)
 Add an element to the hash and to the reverse table.

Detailed Description

template<class T, class K = unsigned int>
class csHashReversible< T, K >

A csHash<> that maintains a reverse hash for indexing keys by values.

Definition at line 34 of file hashr.h.


Constructor & Destructor Documentation

template<class T , class K = unsigned int>
csHashReversible< T, K >::csHashReversible ( int  size = 23,
int  grow_rate = 5,
int  max_size = 20000 
) [inline]

Construct a hash table with an array of the given size, which for optimisation reasons should be a prime number.

Grow_rate is the rate at which the hash table grows: Size doubles once there are size/grow_rate collisions. It will not grow after it reaches max_size.

Here are a few primes: 7, 11, 19, 29, 59, 79, 101, 127, 151, 199, 251, 307, 401, 503, 809, 1009, 1499, 2003, 3001, 5003, 12263, 25247, 36923, 50119, 70951, 90313, 104707. For a bigger list go to http://www.utm.edu/research/primes/

Definition at line 51 of file hashr.h.


Member Function Documentation

template<class T , class K = unsigned int>
bool csHashReversible< T, K >::Delete ( const K &  key,
const T &  value 
) [inline]

Delete all the elements matching the given key and value.

Reimplemented from csHash< T, K >.

Definition at line 78 of file hashr.h.

template<class T , class K = unsigned int>
bool csHashReversible< T, K >::DeleteAll ( const K &  key  )  [inline]

Delete all the elements matching the given key.

Reimplemented from csHash< T, K >.

Definition at line 88 of file hashr.h.

template<class T , class K = unsigned int>
void csHashReversible< T, K >::DeleteAll (  )  [inline]

Delete all the elements.

Reimplemented from csHash< T, K >.

Definition at line 100 of file hashr.h.

template<class T , class K = unsigned int>
const K& csHashReversible< T, K >::GetKey ( const T &  key,
const K &  fallback 
) const [inline]

Get the first key matching the given value, or fallback if there is none.

Definition at line 119 of file hashr.h.

template<class T , class K = unsigned int>
const K* csHashReversible< T, K >::GetKeyPointer ( const T &  key  )  const [inline]

Get a pointer to the first key matching the given value, or 0 if there is none.

Definition at line 110 of file hashr.h.

template<class T , class K = unsigned int>
void csHashReversible< T, K >::Put ( const K &  key,
const T &  value 
) [inline]

Add an element to the hash and reverse table.

Reimplemented from csHash< T, K >.

Definition at line 59 of file hashr.h.

template<class T , class K = unsigned int>
void csHashReversible< T, K >::PutUnique ( const K &  key,
const T &  value 
) [inline]

Add an element to the hash and to the reverse table.

Remarks:

Reimplemented from csHash< T, K >.

Definition at line 69 of file hashr.h.


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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1