GHashTbl< Key, Value > Class Template Reference

General hash table container for O(1) access to table data. More...

#include <GHashTable.h>

List of all members.

Public Member Functions

 GHashTbl (int size=0, bool is_case=true, Key nullkey=0, Value nullvalue=(Value) 0)
 ructs the hash table
virtual ~GHashTbl ()
 Deletes the hash table removing all contents from memory.
GHashTbl< Key, Value > & operator= (GHashTbl< Key, Value > &c)
 Copy operator.
int64 GetSize ()
 Gets the total available entries.
bool SetSize (int64 s)
 Sets the total available entries.
bool GetStringPool ()
 Gets the string pooling setting.
void SetStringPool (bool b)
bool IsCase ()
 Returns whether the keys are case sensitive.
void IsCase (bool c)
 Sets whether the keys are case sensitive.
bool IsOk ()
 Returns true if the object appears to be valid.
int Length ()
 Gets the number of entries used.
bool Add (Key k, Value v)
 Adds a value under a given key.
bool Delete (Key k)
 Deletes a value at 'key'.
Value Find (Key k)
 Returns the value at 'key'.
Value First (Key *k=0)
 Returns the first value.
Value Current (Key *k=0)
 Returns the current value.
Value Next (Key *k=0)
 Returns the next value.
void Empty ()
 Removes all key/value pairs from memory.
int64 Sizeof ()
 Returns the amount of memory in use by the hash table.
void DeleteObjects ()
 Deletes values as objects.
void DeleteArrays ()
 Deletes values as arrays.


Detailed Description

template<typename Key, typename Value>
class GHashTbl< Key, Value >

General hash table container for O(1) access to table data.

Constructor & Destructor Documentation

template<typename Key , typename Value >
GHashTbl< Key, Value >::GHashTbl ( int  size = 0,
bool  is_case = true,
Key  nullkey = 0,
Value  nullvalue = (Value)0 
) [inline]

ructs the hash table

Parameters:
size  Sets the initial table size. Should be 2x your data set.
is_case  Sets the case sensitivity of the keys.
nullkey  The default empty value
nullvalue  The default empty value


Member Function Documentation

template<typename Key , typename Value >
bool GHashTbl< Key, Value >::Add ( Key  k,
Value  v 
) [inline]

Adds a value under a given key.

Parameters:
k  The key to insert the value under
v  The value to insert

Referenced by GCompilerPriv::DoStruct(), GDateTime::GetDaylightSavingsInfo(), GList::OnItemSelect(), GHashTbl< char *, GTypeDef::GMember * >::operator=(), and GHashTbl< char *, GTypeDef::GMember * >::SetSize().

template<typename Key , typename Value >
bool GHashTbl< Key, Value >::Delete ( Key  k  )  [inline]

Deletes a value at 'key'.

Parameters:
k  The key of the value to delete

template<typename Key , typename Value >
void GHashTbl< Key, Value >::SetStringPool ( bool  b  )  [inline]

Sets the string pooling setting. String pooling lowers the number of memory allocs/frees but will waste memory if you delete keys. Good for fairly large static tables.

(only works with using Key='char*')


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

Generated on Wed Dec 1 15:41:03 2010 for Lgi by  doxygen 1.5.7.1