Tools.h++ Manual

104011 Tandem Computers Incorporated 22-47
22
RWTPtrOrderedVector<T>
Synopsis
#include <rw/tpordvec.h>
RWTPtrOrderedVector<T> ordvec;
Description
RWTPtrOrderedVector<T>
is a pointer-based ordered collection. That is, the
items in the collection have a meaningful ordered relationship with respect to
one another and can be accessed by an index number. The order is set by the
order of insertion. Duplicates are allowed. The class is implemented as a
vector, allowing efficient insertion and retrieval from the end of the collection,
but somewhat slower from the beginning of the collection.
The class
T
must have:
well-defined equality semantics (
T::operator==(const T&)
).
Example
#include <rw/tpordvec.h>
#include <rw/rstream.h>
main() {
RWTPtrOrderedVector<double> vec;
vec.insert(new double(22.0));
vec.insert(new double(5.3));
vec.insert(new double(-102.5));
vec.insert(new double(15.0));
vec.insert(new double(5.3));
cout << vec.entries() << " entries\n" << endl;// Prints "5"
for (int i=0; i<vec.length(); i++)
cout << *vec[i] << endl;
vec.clearAndDestroy();
return 0;
}