Tools.h++ Class Reference

Table Of Contents
bool operator()(const K& x, const K& y)
which should return true if x and y are equivalent.
RWTPtrHashMultiMap<K,T,H,EQ> may contain multiple keys that compare equal to each other.
(RWTPtrHashMap<K,T,H,EQ> will not accept a key that compares equal to any key already in the
collection.) Equality is based on the comparison object and not on the == operator.
Persistence
Isomorphic
Examples
//
// tphmap.cpp
//
#include<rw/tphmmap.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";
RWTPtrHashMultiMap<RWCString,int,silly_hash,equal_to<RWCString> >
contest;
contest.insert(new RWCString("First"), new int(7));
contest.insert(&snd, new int(3));
contest.insert(&snd, new int(6)); // duplicate key OK
contest.insert(new RWCString("Third"), new int(2));
cout << "There were " << contest.occurrencesOf(&snd)
<< " second place winners." << endl;
return 0;
}
Program Output:
There were 2 second place winners.
Related Classes
Class RWTPtrHashMap<K,T,H,EQ> offers the same interface to a pointer-based collection that
will not accept multiple keys that compare equal to each other.