Function Objects for Comparison
The associative container-based and the sorted sequence-based collection classes maintain order internally. This ordering is based on a comparison object, an instance of a comparison class you must supply when instantiating the template. A comparison object must contain a const member operator(), the function-call operator, which takes two potential elements of the collection class as arguments and returns a bool value. The returned value should be True if the first argument must precede the second within the collection class, and False otherwise. Often, it is easiest to use one of the function-object classes provided by the C++ Standard Library in the header file <functional>. In particular, use less<T> to maintain elements in increasing order, or greater<T> to maintain them in decreasing order. For example:
#include <functional>
#include <rw/tvset.h>
#include <rw/tools/datetime.h>
RWTValSet<int, std::less<int> > mySet1;
RWTValSet<RWDateTime, std::greater<RWDateTime> > mySet2;
Here mySet1 is a set of integers kept in increasing order, while mySet2 is a set of dates held in decreasing order; that is, from the most recent to the oldest. You can use these comparison objects from the C++ Standard Library as long as the expression (x < y) for the case of less<T>, or (x > y) for the case of greater<T>, are valid expressions that induce a total ordering on objects of type T.