#include <CNCL/HashStatic.h>
CN_HASHSTATIC
CNHashTable
None
CNHashDynamic, CNKey, CNKeyString, CNHashIterator, CNKeyInt
CNHashStatic
is a class which provides a hash table with static capacity
for storing and retrieving CNCL compatible objects.
Constructors:
CNHashStatic(unsigned long cap = DEFAULT_HASH_TABLE_CAPACITY);
CNHashStatic(CNParam *param);
CNHashStatic
. The hash table's capacity is set to
the value passed to CNHashStatic. The capacity is static, therefore, you
cannot change it during the lifetime of an instance of this class.
Destructors:
~CNHashStatic();
CNHashStatic
provides the member functions required by CNCL and
CNHashTable
.
Some member functions defined in CNHashTable
and
implemented in CNHashStatic
demand further explanation:
void store_key(CNKey *k);
get_key()
and
get_object()
should detect it. If you try to store a key into an
already full table, an error message is displayed and the program is
terminated.
bool delete_key(CNKey *k);
FALSE
is returned, otherwise TRUE
.
bool delete_key_absolutely(CNKey *k);
FALSE
is returned, otherwise TRUE
.
The following example shows how to use a CNHashStatic
object in
order to store and retrieve CNCL compatible objects.
CNHashStatic tab(200); CNKeyString ks("Test", NIL); CNObject *obj = &ks; tab.store_key(new CNKeyString("Jabba", obj)); tab.store_key(new CNKeyString("Dabba")); tab.store_key(new CNKeyString("Dooo")); if (tab.get_object(CNKeyString("Jabba")) != obj) cout << "strange behaviour\n"; else cout << "found obj\n"; tab.store_key(new CNKeyInt(10, obj)); // error, key of different type tab.reset_absolutely(); tab.store_key(new CNKeyInt(10, new CNObject)); // okay // free memory of all keys and their objects tab.reset_absolutely_w_obj();
Go to the first, previous, next, last section, table of contents.