Tools.h++ Manual

23-26 104011 Tandem Computers Incorporated
23
RWGSortedVector(val)
RWGSortedVector(val )
|
RWGVector(val )
Synopsis
#include <rw/gsortvec.h>
declare(RWGSortedVector,
val
)
implement(RWGSortedVector,
val
)
RWGSortedVector(
val
) v; // A sorted vector of
val's
.
Description Class
RWGSortedVector
(val) represents a vector of elements of type val,
sorted using an insertion sort. The elements can be retrieved using an index or
a search. Duplicates are allowed. Objects of type
RWGSortedVector
(val) are
declared with macros defined in the standard C++ header file <generic.h>.
Note – It is a value-based collection: items are copied in and out of the collection.
The class val must have:
a default constructor;
well-defined copy semantics
(
val
::
val
(const
val
&)
or equiv.);
well-defined assignment semantics
(
val
::operator=(const
val
&)
or equiv.);
well-defined equality semantics
(
val
::operator==(const
val
&)
or equiv.);
well-defined less-than semantics
(
val
::operator<(const
val
&)
or equiv.).
To use this class you must declare and implement its base class as well as the
class itself. For example, here is how you declare and implement a sorted
collection of doubles:
declare(RWGVector,double) // Declare base class
declare(RWGSortedVector,double)// Declare sorted vector
// In one and only one
.cc
file you must put the following:
implement(RWGVector,double) // Implement base
implement(RWGSortedVector,double) // Implement sorted
vector