Tools.h++ Manual
104011 Tandem Computers Incorporated 22-115
22
RWTValSortedVector<T>
Synopsis
#include <rw/tvsrtvec.h>
RWTValSortedVector<T> sortvec;
Description
RWTValSortedVector<T>
is an ordered collection. That is, the items in the
collection have a meaningful ordered relationship with respect to each other
and can be accessed by an index number. In the case of
RWTValSortedVector<T>
, objects are inserted such that objects "less than"
themselves are before the object, objects "greater than" themselves after the
object. An insertion sort is used. Duplicates are allowed.
Stores a copy of the inserted item into the collection according to an ordering
determined by the less-than (<) operator.
The class
T
must have:
• well-defined copy semantics (
T::T(const T&)
or equiv.);
• well-defined assignment semantics (
T::operator=(const T&)
or equiv.);
• well-defined equality semantics (
T::operator==(const T&)
);
• well-defined less-than semantics (
T::operator(const T&)
);
• a default constructor.
Note that a sorted vector has a length (the number of items returned by
length()
or
entries()
) and a capacity. Necessarily, the capacity is always
greater than or equal to the length. Although elements beyond the collection's
length are not used, nevertheless, in a value-based collection, they are
occupied. If each instance of class T requires considerable resources, then you
should insure that the collection's capacity is not much greater than its length,
otherwise unnecessary resources will be tied up.