vector Function | Description |
vector<Type> aVec; |
Declare aVec as an empty vector
for storing Type values |
vector<Type> aVec(n); |
Declare aVec as a vector
containing n default values of type
Type |
vector<Type> aVec(n, val); |
Declare aVec as a vector
containing n copies of value val |
aVec[i] |
Access the character in aVec whose index is i
(without checking that i is valid) |
aVec.at(i) |
Access the character in aVec whose index is i
(checking that i is valid) |
aVec.size() |
Return the number of values in aVec |
aVec.capacity() |
Return the number of values aVec can store |
aVec.reserve(n) |
Change the capacity of aVec to n |
aVec.push_back(value); |
Append value at aVec's end |
aVec.pop_back(); |
Erase the last value in aVec |
aVec.front() |
Return a reference to the first element of aVec |
aVec.back() |
Return a reference to the last element of aVec |
aVec = vec2 |
Make aVec a copy of vec2 |
aVec.clear() |
Erase all of the values in aVec |