quick start:g++ [flags ...] file ... #include <ColorHash.h>; Integral::COLOR get(const GraphVertex<TObject>* key); boolean set(const GraphVertex<TObject>* key, Integral::COLOR value); boolean insert(const GraphVertex<TObject>* key, Integral::COLOR value); boolean remove(const GraphVertex<TObject>* key);
// declare the graph arc object
//
ColorHash<Char> hash;
GraphVertex<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"ColorHash";
static const String GV_KEY_CLASS_NAME = L"GVKey";
static const String GV_COLOR_CLASS_NAME = L"GVColor";
typedef ColorHash<TObject> CHASH;
HashTable<GVKey<TObject>, GVColor>* 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);
~ColorHash();
ColorHash();
ColorHash(const CHASH& arg);
boolean assign(const CHASH& arg);
ColorHash& operator=(const ColorHash& arg);
boolean eq(const ColorHash& 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 GraphVertex<TObject>* key);
const Integral::COLOR get(const GraphVertex<TObject>* key) const ;
boolean set(const GraphVertex<&TObject>* key, Integral::COLOR value);
boolean insert(const GraphVertex<TObject>* key, Integral::COLOR value);
boolean remove(const GraphVertex<TObject>* key);
boolean containsKey(const GraphVertex* key) const;
boolean containsValue(const Integral::COLOR value) const;
// declare a hash table
//
ColorHash<Char> hash;
// create some data
//
GraphVertex<Char> vert_01;
GraphVertex<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__);
}