Tools.h++ Class Reference

Table Of Contents
which returns true if x and its partner should precede y and its partner within the collection. The
structure less<T> from the C++-standard header file <functional> is an example.
RWTValMultiMap<K,T,C> may contain multiple keys that compare equal to each other.
(RWTValMap<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 map of RWCStrings and RWDates is exercised.
//
// tvmmbday.cpp
//
#include <rw/tvmmap.h>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <iostream.h>
#include <function.h>
main(){
typedef RWTValMultiMap<RWCString, RWDate, less<RWCString> >
RWMMap;
RWMMap birthdays;
birthdays.insert("John", RWDate(12, "April",1975));
birthdays.insert("Ivan", RWDate(2, "Nov", 1980));
birthdays.insert("Mary", RWDate(22, "Oct", 1987));
birthdays.insert("Ivan", RWDate(19, "June", 1971));
birthdays.insert("Sally",RWDate(15, "March",1976));
birthdays.insert("Ivan", RWDate(6, "July", 1950));
// How many "Ivan"s?
RWMMap::size_type n = birthdays.occurrencesOf("Ivan");
RWMMap::size_type idx = 0;
cout << "There are " << n << " Ivans:" << endl;
RWMMap::iterator iter = birthdays.std().lower_bound("Ivan");
while (++idx <= n)
cout << idx << ". " << (*iter++).second << endl;
return 0;