Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
Hashtable Class Reference

List of all members.

Public Member Functions

 Hashtable (UINT32(*func1)(void *), SINT32(*func2)(void *, void *), SINT32 capacity=1000, float loadFactor=0.75)
 ~Hashtable ()
CAMutexgetMutex ()
bool isEmpty ()
 Tests if the hashtable is empty.
bool containsKey (void *key)
 Testet, ob ein bestimmter Schlssel im Hashtable enthalten ist.
void * getValue (void *key)
 Sucht den zu einem Schlssel (key) passenden Wert (value)
UINT32 getSize ()
UINT32 getCapacity ()
void * put (void *key, void *value)
 Mit dieser Funktion wird ein neuer Eintrag bestehend aus einem Zugriffsschlssel (key) und dessen Wert (value) in den Hashtable eingefgt.
void * remove (void *key)
 entfernt einen Eintrag aus einem Hashtable
void clear (SINT8 keyMode=HASH_EMPTY_NONE, SINT8 valueMode=HASH_EMPTY_NONE)

Static Public Member Functions

static UINT32 stringHash (UINT8 *str)
static SINT32 stringCompare (UINT8 *a, UINT8 **b)
static UINT32 hashUINT64 (UINT64 *a_number)
static SINT32 compareUINT64 (UINT64 *a_numberA, UINT64 *a_numberB)
static UINT32 hashUINT32 (UINT32 *a_number)
static SINT32 compareUINT32 (UINT32 *a_numberA, UINT32 *a_numberB)

Protected Member Functions

bool rehash ()
 Der Hashtable wird in der Kapazitt verdoppelt und neu aufgebaut.
struct EntrygetHashEntry (void *key)
 Gibt den zu einem Schlssel passenden Eintrag eines Hashtables zurueck.

Protected Attributes

SINT32 m_capacity
SINT32 m_count
SINT32 m_threshold
SINT32 m_modCount
float m_loadFactor
struct Entry ** m_table
UINT32(* m_hashFunc )(void *)
SINT32(* m_compareFunc )(void *, void *)

Private Attributes

CAMutexm_pMutex

Constructor & Destructor Documentation

Hashtable::Hashtable ( UINT32(*)(void *)  func1,
SINT32(*)(void *, void *)  func2,
SINT32  capacity = 1000,
float  loadFactor = 0.75 
)

Member Function Documentation

void Hashtable::clear ( SINT8  keyMode = HASH_EMPTY_NONE,
SINT8  valueMode = HASH_EMPTY_NONE 
)
static SINT32 Hashtable::compareUINT32 ( UINT32 a_numberA,
UINT32 a_numberB 
) [static]
static SINT32 Hashtable::compareUINT64 ( UINT64 a_numberA,
UINT64 a_numberB 
) [static]
bool Hashtable::containsKey ( void *  key)

Testet, ob ein bestimmter Schlssel im Hashtable enthalten ist.

Parameters:
keyder gesuchte Schlssel
Returns:
success TRUE, wenn der Schlssel enthalten ist, FALSE, wenn nicht

References getHashEntry().

References m_capacity.

struct Entry * Hashtable::getHashEntry ( void *  key) [read, protected]

Gibt den zu einem Schlssel passenden Eintrag eines Hashtables zurueck.

Parameters:
keyder zu suchende Schlssel
Returns:
entry der gefundene Eintrag oder NULL

References Entry::e_Key, Entry::e_Next, m_capacity, m_compareFunc, m_hashFunc, and m_table.

Referenced by containsKey(), and getValue().

References m_count.

Referenced by CAAccountingInstance::getNrOfUsers().

void * Hashtable::getValue ( void *  key)
static UINT32 Hashtable::hashUINT32 ( UINT32 a_number) [static]
static UINT32 Hashtable::hashUINT64 ( UINT64 a_number) [static]

Tests if the hashtable is empty.

Returns:
true if empty; false otherwise

References m_count.

void * Hashtable::put ( void *  key,
void *  value 
)

Mit dieser Funktion wird ein neuer Eintrag bestehend aus einem Zugriffsschlssel (key) und dessen Wert (value) in den Hashtable eingefgt.

Gibt es diesen Schlssel bereits im Hashtable, wird der alte Eintrag berschrieben.

einen neuen Eintrag in einen Hashtable einfgen

Parameters:
keyder Schlssel
valueder zugehrige Wert
Returns:
the old value if a value has been overwritten, or NULL if the value did not exist before

References Entry::e_Key, Entry::e_Next, Entry::e_Value, m_capacity, m_compareFunc, m_count, m_hashFunc, m_table, m_threshold, and rehash().

Referenced by CAAccountingInstance::CAAccountingInstance(), and CAAccountingInstance::handleChallengeResponse_internal().

bool Hashtable::rehash ( ) [protected]

Der Hashtable wird in der Kapazitt verdoppelt und neu aufgebaut.

Returns:
success true, wenn die Kapazitt verdoppelt werden konnte, false, wenn nicht

References Entry::e_Key, Entry::e_Next, m_capacity, m_hashFunc, m_loadFactor, m_modCount, m_table, m_threshold, and CAMsg::printMsg().

Referenced by put().

void * Hashtable::remove ( void *  key)

entfernt einen Eintrag aus einem Hashtable

Mit dieser Funktion entfernt man den zum Schlssel (key) gehrigen Eintrag aus dem Hashtable.

Parameters:
keyder Schlssel
Returns:
value der zum Schlssel gehrende Wert

References Entry::e_Key, Entry::e_Next, Entry::e_Value, m_capacity, m_compareFunc, m_count, m_hashFunc, and m_table.

Referenced by CAAccountingInstance::cleanupTableEntry(), CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::~CAAccountingInstance().

static SINT32 Hashtable::stringCompare ( UINT8 a,
UINT8 **  b 
) [static]
static UINT32 Hashtable::stringHash ( UINT8 str) [static]

Member Data Documentation

SINT32(* Hashtable::m_compareFunc)(void *, void *) [protected]
UINT32(* Hashtable::m_hashFunc)(void *) [protected]
float Hashtable::m_loadFactor [protected]

Referenced by Hashtable(), rehash(), and ~Hashtable().

Referenced by Hashtable(), rehash(), and ~Hashtable().

Referenced by getMutex(), Hashtable(), and ~Hashtable().

struct Entry** Hashtable::m_table [protected]

Referenced by Hashtable(), put(), rehash(), and ~Hashtable().