quick start:g++ [flags ...] file ... #include <BiColorHash.h>; Integral::COLOR get(const BiGraphVertex<TObject>* key); boolean set(const BiGraphVertex<TObject>* key, Integral::COLOR value); boolean insert(const BiGraphVertex<TObject>* key, Integral::COLOR value); boolean remove(const BiGraphVertex<TObject>* key);
// declare the graph arc object
//
BiColorHash<Char> hash;
BiGraphVertex<Char> vertex;
// insert a vertex into the hash table and associate a color with it
//
hash.insert(&vertex, Integral::WHITE);
if (hash.get(&vertex) != Integral::WHITE) {
return Error::handle(name(), L"insert/get", Error::TEST,
__FILE__, __LINE__);
}
// change the color associated with the vertex
//
hash.set(&vertex, Integral::BLUE);
if (hash.get(&vertex) != Integral::BLUE) {
return Error::handle(name(), L"insert/set", Error::TEST,
__FILE__, __LINE__);
}
// remove the vertex from the graph
//
hash.remove(&vertex);
// the hash table should be empty
//
if (!hash.isEmpty()) {
return Error::handle(name(), L"isEmpty", Error::TEST,
__FILE__, __LINE__);
}
description:
static const String CLASS_NAME = L"BiColorHash";
static const String GV_KEY_CLASS_NAME = L"GVKey";
static const String GV_COLOR_CLASS_NAME = L"GVColor";
typedef BiColorHash<TObject> CHASH;
HashTable<BiGVKey<TObject>, BiGVColor>* hash_d;
static Integral::DEBUG debug_level_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
static boolean setDebug(Integral::DEBUG level);
boolean debug(const unichar* message);
~BiColorHash();
BiColorHash();
BiColorHash(const CHASH& arg);
boolean assign(const CHASH& arg);
BiColorHash& operator=(const BiColorHash& arg);
boolean eq(const BiColorHash& arg) const;
i/o methods are not defined for this class.
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
long getNumItems() const;
boolean isEmpty() const;
Integral::COLOR get(const BiGraphVertex<TObject>* key);
const Integral::COLOR get(const BiGraphVertex<TObject>* key) const ;
boolean set(const BiGraphVertex<&TObject>* key, Integral::COLOR value);
boolean insert(const BiGraphVertex<TObject>* key, Integral::COLOR value);
boolean remove(const BiGraphVertex<TObject>* key);
boolean containsKey(const BiGraphVertex* key) const;
boolean containsValue(const Integral::COLOR value) const;
// declare a hash table
//
BiColorHash<Char> hash;
// create some data
//
BiGraphVertex<Char> vert_01;
BiGraphVertex<Char> vert_02;
// insert vertices into the hash and associate colors with them
//
hash.insert(&vert_01, Integral::WHITE);
hash.insert(&vert_02, Integral::GREY);
if (hash.get(&vert_01) != Integral::WHITE) {
return Error::handle(name(), L"insert/get", Error::TEST,
__FILE__, __LINE__);
}
if (hash.get(&vert_02) != Integral::GREY) {
return Error::handle(name(), L"insert/get", Error::TEST,
__FILE__, __LINE__);
}
// remove the vertices from the graph
//
hash.remove(&vert_01);
hash.remove(&vert_02);
if (hash.containsKey(&vert_01)) {
return Error::handle(name(), L"containsKey", Error::TEST,
__FILE__, __LINE__);
}
if (hash.containsValue(Integral::GREY)) {
return Error::handle(name(), L"containsValue", Error::TEST,
__FILE__, __LINE__);
}