course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

function members

Prev | Next | Lab 9

vector FunctionDescription
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


vector Functions Using iterators

aVec.begin() Return an iterator to the first element of aVec
aVec.end() Return an iterator pointing beyond the last element of aVec
aVec.erase(it) Remove the element of aVec pointed to by iterator it
aVec.insert(it, val) Insert value val before the element of aVec pointed to by iterator it

Prev | Next | Lab 9

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Friday, August 25, 2000 at 9:30:07 AM.
visitors to this page.