Tools.h++ Class Reference

Table Of Contents
structure less<T> from the C++-standard header file <functional> is an example. Note that keys will
be dereferenced before being compared.
RWTPtrMultiMap<K,T,C> may contain multiple keys that compare equal to each other.
(RWTPtrMap<K,T,C> 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. Given a
comparison object comp, keys a and b are equal if
!comp(a,b) && !comp(b,a).
Persistence
Isomorphic.
Examples
In this example, a multimap of RWCStrings and RWDates is exercised.
//
// tpmmap.cpp
//
#include <rw/tpmmap.h>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <iostream.h>
main(){
typedef RWTPtrMultiMap<RWCString, RWDate, less<RWCString> >
RWMMap;
RWMMap birthdays;
birthdays.insert(new RWCString("John"),
new RWDate(12, "April", 1975));
birthdays.insert(new RWCString("Ivan"),
new RWDate(2, "Nov", 1980));
birthdays.insert(new RWCString("Mary"),
new RWDate(22, "Oct", 1987));
birthdays.insert(new RWCString("Ivan"),
new RWDate(19, "June", 1971));
birthdays.insert(new RWCString("Sally"),
new RWDate(15, "March", 1976));
birthdays.insert(new RWCString("Ivan"),
new RWDate(6, "July", 1950));
// How many "Ivan"s?
RWCString ivanstr("Ivan");
RWMMap::size_type n = birthdays.occurrencesOf(&ivanstr);
RWMMap::size_type idx = 0;
cout << "There are " << n << " Ivans:" << endl;