Description
The Vector class stores a resizable array of objects.
Operators
- object&
operator[]( int index ) – Accesses value at location
index. Throws an exception if
index is out of range.
- Vector&
operator =( Vector v ) – Copies the values from Vector
v. Returns this object.
- bool
operator ==( Vector v ) – Returns true if both Vectors contain
the same number of items, and each item is equal to the corresponding item in
the other Vector.
Methods
- void
clear() – Empties the Vector.
- bool
empty() – Returns true if the Vector is empty.
- size_t
size() – Returns the count of items in the Vector.
- object&
front() – Accesses value at the beginning of the Vector.
Throws an exception if the Vector is empty.
- object&
back() – Accesses value at the end of the Vector. Throws an
exception if the Vector is empty.
- void
push_back( object o ) – Inserts the value
o at the end of the Vector.
- void
pop_back() – Removes value from the end of the Vector. Do not
invoke this on an empty Vector.
- void
insert_at(int index, object o) – Inserts
o at position
index. Throws an exception if
index is out of range.
- void
erase_at(int index) – Removes object at position
index. Throws an exception if
index is out of range.
- void
resize(size_t count) – Resizes the Vector to
contain count elements. If the current size is greater
than the
count, the container is reduced to its
first count elements. If the current size is less
than count, additional elements are appended and
default-initialized.
- void
resize(size_t count, object o) – Resizes the Vector to
contain count elements. If the current size is greater
than the
count, the container is reduced to its
first count elements. If the current size is less
than count, additional elements are appended and copied from
o.
- void
reserve( size_t count ) – Pre-allocates a buffer of size
count for future use.
- size_t
capacity() – Returns the current buffer size.
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.