Main Page   Class Hierarchy   Compound List   File List   Compound Members  

TValHashMapT< K, V, U > Class Template Reference

Template class that maintains a collection of keys (K), value (V) pairs which are stored according to the hash utility class U. More...

#include <TValHashMapT.hh>

List of all members.

Public Methods

 TValHashMapT ()
 Constructs an empty hash map.

 TValHashMapT (const TValHashMapT< K, V, U > &map)
 Copy constructor.

 ~TValHashMapT ()
 Destructor.

void Apply (void(*fn)(const K *, V *, void *), void *d)
 Applies the user defined function to every key, value pair in self.

void Clear ()
 Removes all keys from self.

bool Contains (const K &k)
 Check if there exists a key in self that compares equal to k.

int Entries ()
 Query number of keys in self.

bool FindValue (const K &k, V &v)
 Find value associated with key.

bool Insert (const K &k, const V &v)
 Insert a key, value pair to the collection.

bool Remove (const K &k)
 Remove a key from the collection.

void Shrink (bool flag)
 Enable or dissable shrinking of bucket array when keys are removed.

V & operator[] (const K &k)
 Index operator.

TValHashMapT< K, V, U > & operator= (const TValHashMapT< K, V, U > &map)
 Assignment operator.


Detailed Description

template<class K, class V, class U>
class TValHashMapT< K, V, U >

Template class that maintains a collection of keys (K), value (V) pairs which are stored according to the hash utility class U.

The class U should contain the static methods Hash and Equal to calculate the hash of K objects and to compare K objects for equality.

See also:
THashInt

THashString

THashT

Author:
Johan Bolmsjo <johan@nocrew.org>


Member Function Documentation

template<class K, class V, class U>
void TValHashMapT< K, V, U >::Apply void(*    fn)(const K *, V *, void *),
void *    d
 

Applies the user defined function to every key, value pair in self.

Parameters:
fn Function pointer to your function.
d Client data to pass to your function.

template<class K, class V, class U>
bool TValHashMapT< K, V, U >::Contains const K &    k [inline]
 

Check if there exists a key in self that compares equal to k.

Parameters:
k Key to look for.
Returns:
true, match or false, no match.

template<class K, class V, class U>
int TValHashMapT< K, V, U >::Entries   [inline]
 

Query number of keys in self.

Returns:
Number of keys.

template<class K, class V, class U>
bool TValHashMapT< K, V, U >::FindValue const K &    k,
V &    v
 

Find value associated with key.

If the key is not found, v is not updated.

Parameters:
k Key to look for.
Returns:
true, match or false, no match.

template<class K, class V, class U>
bool TValHashMapT< K, V, U >::Insert const K &    k,
const V &    v
 

Insert a key, value pair to the collection.

Parameters:
k Key to insert.
v Value to insert,
Returns:
true, key inserted or false, key already exists.

template<class K, class V, class U>
V & TValHashMapT< K, V, U >::operator[] const K &    k
 

Index operator.

Returns a reference to the value associated with the key k. The value may be modified.

template<class K, class V, class U>
bool TValHashMapT< K, V, U >::Remove const K &    k
 

Remove a key from the collection.

Parameters:
k Key to remove.
Returns:
true, key removed or false, no such key.

template<class K, class V, class U>
void TValHashMapT< K, V, U >::Shrink bool    flag [inline]
 

Enable or dissable shrinking of bucket array when keys are removed.

This saves memory but costs some CPU time. It is enabled by default.

Parameters:
flag true, enable or false, disable.


The documentation for this class was generated from the following file:
Generated on Sat Feb 15 18:37:16 2003 for Tools by doxygen1.3-rc2