#include <CNCL/HashTable.h>
CN_HASHTABLE
CNObject
CNHashStatic, CNHashDynamic
CNKey, CNKeyString, CNKeyInt, CNHashIterator, CNManager
CNHashTable
is an abstract base class for storing and retrieving
CNCL compatible objects.
Constructors:
CNHashTable();
CNHashTable(CNParam *param);
CNHashTable
.
CNHashTable
defines the following structs and constants:
const unsigned long DEFAULT_HASH_TABLE_CAPACITY = 101;
struct HashEntry { CNKey *he_CNKey; unsigned long he_HashValue; };
CNHashTable
provides the following virtual functions which
have to be defined in derived classes:
virtual void store_key(CNKey *k) = 0;
virtual void store_key(CNKey &k) = 0;
HashTable
). The actual hash table is a homogenous table.
Therefore, only keys of the same type may be stored into one
table. If you nevertheless try to store keys of a different type into one
table, it might be detected by the methods get_key()
and
get_object()
. Refer to the description of the derived classes
for further information.
virtual CNKey *get_key(CNKey *k) const = 0;
virtual CNKey *get_key(CNKey &k) const = 0;
NIL
is returned.
virtual CNObject *get_object(CNKey *k) const = 0;
virtual CNObject *get_object(CNKey &k) const = 0;
NIL
is returned.
virtual bool reset() = 0;
FALSE
is returned, otherwise
TRUE
.
virtual bool reset_absolutely() = 0;
FALSE
is returned, otherwise TRUE
.
virtual bool reset_absolutely_w_obj() = 0;
FALSE
is returned, otherwise TRUE
.
virtual bool delete_key(Key *k) = 0;
virtual bool delete_key(CNKey &k);
k
from the actual hash table. This method
neither frees the memory allocated for the key stored in the hash table
nor for the object stored in the key. If the supplied key does not match
any in the table, FALSE
is returned, otherwise TRUE
.
virtual bool delete_key_absolutely(CNKey *k) = 0;
virtual bool delete_key_absolutely(CNKey &k) = 0;
k
from the actual hash table. This method
frees the memory allocated for the key stored in the hash table, but
does not free the memory allocated for the object stored in the
key. If the supplied key does not match any in the table, FALSE
is returned, otherwise TRUE
.
virtual bool delete_key_absolutely_w_obj(CNKey *k) = 0;
virtual bool delete_key_absolutely_w_obj(CNKey &k) = 0;
k
from the actual hash table. This method
frees the memory allocated for the key stored in the hash table and
frees the memory allocated for the object stored in the key. If the
supplied key does not match any in the table, FALSE
is returned,
otherwise TRUE
.
virtual bool is_full() const = 0;
TRUE
is returned,
otherwise FALSE
.
virtual bool is_empty() const = 0;
TRUE
is returned, otherwise
FALSE
.
virtual unsigned long get_num_entries() const = 0;
virtual unsigned long get_capacity() const = 0;
Go to the first, previous, next, last section, table of contents.