Tools.h++ Class Reference

Table Of Contents
Equivalent keys within the collection will be grouped together based on an equality object of
type EQ. EQ must ensure this grouping via public member
bool operator()(const K& x, const K& y)
which should return true if x and y are equivalent.
RWTPtrHashMap<K,T,H,EQ> will not accept a key that compares equal to any key already in
the collection. (RWTPtrHashMultiMap<K,T,H,EQ> may contain multiple keys that compare
equal to each other.) Equality is based on the comparison object and not on the == operator.
Persistence
Isomorphic
Examples
//
// tphmap.cpp
//
#include<rw/tphdict.h>
#include<rw/cstring.h>
#include<iostream.h>
struct silly_hash{
unsigned long operator()(RWCString x) const
{ return x.length() * (long)x(0); }
};
int main(){
RWCString snd = "Second";
RWTPtrHashMap<RWCString,int,silly_hash,equal_to<RWCString> >
contest;
contest.insert(new RWCString("First"), new int(7));
contest.insert(&snd,new int(3));
//duplicate insertion rejected
contest.insert(&snd,new int(6));
contest.insert(new RWCString("Third"), new int(2));
cout << "There was "
<< contest.occurrencesOf(new RWCString("Second"))
<< " second place winner." << endl;
return 0;
}
Program Output: