Tools.h++ Manual

104011 Tandem Computers Incorporated 23-29
23
Public member functions val
operator()(size_t i) const;
Return the
i
'th value in the vector. The index
i
must be between 0 and the
length of the vector less one. No bounds checking is performed.
val
operator[](size_t i) const;
Return the
i
'th value in the vector. The index
i
must be between 0 and the
length of the vector less one. Bounds checking is performed.
size t entries() const;
Returns the number of items currently in the collection.
size_t index(
val
v);
Return the index of the item with value
v
. The value "
RW_NPOS"
is returned if
the value does not occur in the vector. A binary search, using the comparison
function, is done to find the value. If duplicates are present, the index of the
first instance is returned.
RWBoolean insert(
val
v);
Insert the new value
v
into the vector. A binary search, using the comparison
function, is performed to determine where to insert the value. The item will be
inserted after any duplicates. If the insertion causes the vector to exceed its
capacity, it will automatically be resized by an amount given by
RWDEFAULT_RESIZE
.
void resize(size_t newCapacity);
Change the capacity of the collection to
newCapacity
, which must be at least
as large as the present number of items in the collection.
Note – The actual number of items in the collection does not change, just the capacity.