Sign in or register
New: become our partner. Also, now you can submit your own articles!

C++ STL vector class cheatsheet

C++

by dsilva, 11:56 27-11-2007 (updated at 19:26 13-03-2008)

Quick reference to the C++ vector class.
Next is a brief description of what you can find in the pdf.

Method
Description
assign
Fills the vector with a given value.
at
Returns a reference to the element at the given index.
back
Returns a reference to the vector's last element.
begin
Returns an iterator to the first element of the vector.
capacity
Returns the number of allocated positions in the vector.
clear
Removes all the elements from the vector.
empty
Returns true if the vector is empty.
end
Returns an iterator to the position just after the last element of the vector.
erase
Erases a set of elements from the string.
front
Returns a reference to the first element of the vector.
insert
Inserts an element into given position in the vector.
max_size
Returns the maximum number of elements the vector can hold.
pop_back
Removes the element at the end of the vector.
push_back
Inserts an element at the end of the vector.
rbegin
Returns a reverse iterator to the end of the vector.
rend
Returns a reverse iterator to the beginning of the vector.
reserve
Sets the minimum capacity of the vector.
resize
Alters the size of the vector and initiates new positions.
size
Returns the number of elements in the vector.
swap
Swaps the content of the vector with the content of a container.

Comments

No comments.

Leave a comment

RSS article feed RSS article feed

© 2007-2009 Coconuts. Contact us.