Tools.h++ Class Reference

Table Of Contents
Persistence
Isomorphic
Example
//
// tvhmsstr.cpp
//
#include <rw/tvhasht.h>
#include <rw/cstring.h>
#include <iostream.h>
struct silly_hash{
unsigned long operator()(RWCString x) const
{ return x.length() * (long)x[0]; }
};
main(){
RWTValHashMultiSet<RWCString,silly_hash,equal_to<RWCString> > set1;
RWTValHashMultiSet<RWCString,silly_hash,equal_to<RWCString> > set2;
set1.insert("one");
set1.insert("two");
set1.insert("three");
set1.insert("one"); // OK: duplicates allowed
set1.insert("one");
cout << set1.entries() << endl; // Prints "5"
set2.insert("one");
set2.insert("five");
set2.insert("one");
cout << ((set1.isEquivalent(set2)) ? "TRUE" : "FALSE") << endl;
// Prints "FALSE"
set2.intersection(set1);
set1.clear();
cout << set1.entries() << endl; // Prints "0"
cout << set2.entries() << endl; // Prints "2"
return 0;
}
Related Classes
Class RWTValHashSet<T,H,EQ> offers the same interface to a collection that will not accept multiple items that compare
equal to each other.
Class rw_hashmultiset<T,H,EQ> is the C++-standard compliant collection that serves as the underlying implementation for
RWTValHashMultiSet<T,H,EQ>.