Tools.h++ Manual

104011 Tandem Computers Incorporated 22-101
22
Example
Program output:
5 entries
22
5.3
-102.5
15
5.3
Public constructor
RWTValOrderedVector<T>(size_t capac=RWDEFAULT_CAPACITY);
Create an empty ordered vector with capacity
capac
. Should the number of
items exceed this value, the vector will be resized automatically.
RWTValOrderedVector<T>(const RWTValOrderedVector<T>& c);
Constructs a new ordered vector as a copy of
c
. The copy constructor of all
elements in the vector will be called. The new vector will have the same
capacity and number of members as the old vector.
#include <rw/tvordvec.h>
#include <rw/rstream.h>
main() {
RWTValOrderedVector<double> vec;
vec.insert(22.0);
vec.insert(5.3);
vec.insert(-102.5);
vec.insert(15.0);
vec.insert(5.3);
cout << vec.entries() << " entries\n" << endl; // Prints "5"
for (int i=0; i<vec.length(); i++)
cout << vec[i] << endl;
return 0;
}