Tools.h++ Class Reference

Table Of Contents
Stores a pointer to the inserted item into the collection according to an ordering determined by the
less-than (<) operator.
The class T must have:
well-defined equality semantics (T::operator==(const T&));
well-defined less-than semantics (T::operator<(const T&));
Although it is possible to alter objects that are referenced by pointers within a
RWTPtrSortedVector<T>, it is dangerous since the changes may affect the way that operator<() and
operator==() behave, causing the RWTPtrSortedVector<T> to become unsorted.
Persistence
Isomorphic
Example
This example inserts a set of dates into a sorted vector in no particular order, then prints them out in
order.
#include <rw/tpsrtvec.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
main() {
RWTPtrSortedVector<RWDate> vec;
vec.insert(new RWDate(10, "Aug", 1991));
vec.insert(new RWDate(9, "Aug", 1991));
vec.insert(new RWDate(1, "Sep", 1991));
vec.insert(new RWDate(14, "May", 1990));
vec.insert(new RWDate(1, "Sep", 1991)); // Add a duplicate
vec.insert(new RWDate(2, "June", 1991));
for (int i=0; i<vec.length(); i++)
cout << *vec[i] << endl;
vec.clearAndDestroy();
return 0;
}
Program output
May 14, 1990
June 2, 1991
August 9, 1991
August 10, 1991
September 1, 1991