Tools.h++ Class Reference

Table Of Contents
must ensure this grouping via public member
bool operator()(const T& x, const T& y)
which should return true if x and y are equivalent, false otherwise.
RWTPtrHashSet<T,H,EQ> will not accept an item that compares equal to an item already in the
collection. (RWTPtrHashMultiSet<T,H,EQ> may contain multiple items that compare equal to
each other.) Equality is based on the equality object and not on the == operator.
Persistence
Isomorphic
Example
//
// tphset2.cpp
//
#include <rw/tphset.h>
#include <rw/cstring.h>
#include <iostream.h>
struct silly_hash{
unsigned long operator()(RWCString x) const
{ return x.length() * (long)x(0); }
};
main(){
RWTPtrHashSet<RWCString,silly_hash,equal_to<RWCString> > set1;
RWTPtrHashSet<RWCString,silly_hash,equal_to<RWCString> > set2;
set1.insert(new RWCString("one"));
set1.insert(new RWCString("two"));
set1.insert(new RWCString("three"));
set1.insert(new RWCString("one")); // Duplicate insertion rejected
cout << set1.entries() << endl; // Prints "3"
set2 = set1;
cout << ((set1.isEquivalent(set2)) ? "TRUE" : "FALSE") << endl;
// Prints "TRUE"
set2.difference(set1);
set1.clearAndDestroy();
cout << set1.entries() << endl; // Prints "0"
cout << set2.entries() << endl; // Prints "0"