Operation |
Effect |
container_name <my_type> C |
Creates an empty
container "C" without any element |
container_name <my_type> C2(C1) | Copies the container C1 into a
new container C2 |
container_name <my_type> C(beg,end) | Creates a container and
initializes it with the elements of the range [beg,end) |
C.clear(
) |
Deletes all elements and frees
the memory (anyway, the container's life ends automatically at the end
of the scope where it is declared) |
C.size( ) |
Returns the actual numer of
elements |
C.empty(
) |
Returns "true" if the container
is empty, "false" if it is not |
C.max_size(
) |
Returns the maximum number of
elements possible |
C1= = C2 |
Logical: returns whether C1 is
equal to C2 |
C1 != C2 |
Logical: returns whether C1 is
not equivalent to C2 |
C1 <
C2, (C1<= C2) |
Logical: returns whether each
entry of C1 is less than ( less or equal to) the corresponding
entry of C2 |
C1 > C2, (C1>= C2) | Logical: returns whether each entry of C1 is greater than ( greater or equal to) the corresponding entry of C2 |
C1=C2 |
Assignment |
C1.swap(C2)
, or swap(C1,C2) |
Swap |
C.begin(
) |
Returns an iterator for the
first element |
C.end ( ) |
Returns an iterator for the last element |
C.rbegin(
) |
Returns a reverse iterator for
the first element of a reverse iteration |
C.rend( ) |
Returns a reverse iterator for the last element of a reverse iteration |
C.insert(pos,elem
) |
Inserts a copy of elem at
location pos |
C.erase(beg,end) |
Removes all the elements of the
range [beg,end) |
C.clear(
) |
Makes the container empty |
Operation |
Effect |
vector<type> C |
Creates an empty vector called C
without
any element |
vector<type> C2(C1) |
Creates a vector C2 that is the
copy of C1 (all the elements are copied) |
vector<type> C(n) |
Creates a vector with n elements |
vector<type> C(n,elem) |
Creates a vector featuring n
copies of element elem |
vector<type> C(beg,end) |
Creates a vector initialized
with the elements of the range [beg,end) |
Operation |
Effect |
C.capacity(
) |
Returns the maximum possible
number of elements without reallocation |
C.reserve(my_value)
|
Enlarges capacity, if not enough
yet |
Operation |
Effect |
C.assign
(n,elem) |
Assigns n copies of element elem |
C.assign(beg,end) |
Assigns the elements of the
range [beg,end) |
Operation |
Effect |
C.at(idx) |
Returns the element with index
idx (throws range exception if idx is out of range) |
C[idx] |
Returns the element with index
idx with no range checking |
C.front(
) |
Returns the first element (no
check whether the first element exists) |
C.back( ) |
Returns the last element (no
check whether the last element exists) |
Operation |
Effect |
C.push_back(elem) |
Appends a copy of elem |
C.pop_back(
) |
Removes the last element |
C.erase(
) |
Removes the element at iterator
position and returns the position of the next element |
C.erase(beg,end) |
Removes all elements of the
range [beg,end) and returns the position of the next element |
C.resize(num)
|
Change the number of elements to
num |
C.resize(num,elem) |
Change the number of elements to
num (if the size grows, new elements are afected the value elem) |
Operation |
Effect |
set<type,opt> C |
Creates an empty set called C
without
any element |
set<type,opt> C2(C1) |
Creates a set C2 that is the
copy of C1 (all the elements are copied) |
set<type,opt> C(beg,end) |
Creates a set initialized
with the elements of the range [beg,end) |
Operation |
Effect |
C.count
(elem) |
Return the number of elements
with value elem |
C.find
(elem) |
Returns the first element with
value elem, or C.end( ) |
C.lower_bound
(elem) |
Returns the first element >
or = to elem |
C.upper_bound
(elem) |
Returns the first element >
elem |
C.equal_range
(elem) |
Returns the position of the
first element = = elem and the position of the last element = = to elem |
Operation |
Effect |
C.erase(elem) | Removes all elements having for
value elem and returns the number of removed elements |
C.erase(pos)
|
Removes the element at iterator
position pos and returns nothing |
C.erase(beg,end) |
Removes all elements of the
range [beg,end) and returns nothing |
C.resize(num)
|
Change the number of elements to
num |
Operation |
Effect |
C.insert (elem) | Insert a copy of elem and
returns the position of the new element |
C.insert (pos,elem) | Insert a copy of elem and
returns the position of the new element (insert starts the search from
position pos) |
C.insert (beg,end) | Insert a copy of all elements of
the range [beg,end) |
Operation |
Effect |
C.insert (elem) | Insert a copy of elem, returns
the position of the new element and whether it succeeded |
C.insert (pos,elem) | Insert a copy of elem, returns
the position of the new element (insert starts the search from position
pos) and whether it succeded |
Operation |
Effect |
map<type_key,type_value,opt> C |
Creates an empty map called C
without
any element |
map<type_key,type_value,opt> C2(C1) |
Creates a map C2 that is the
copy of C1 (all the elements are copied) |
map<type_key,type_value,opt>
C(beg,end) |
Creates a map initialized
with the elements of the range [beg,end) |
Operation |
Effect |
C.count
(elem_key) |
Return the number of elements
with key elem_key |
C.find
(elem_key) |
Returns the first element with
key elem_key, or C.end( ) |
C.lower_bound
(elem_key) |
Returns the first element with key > or = to elem_key |
C.upper_bound
(elem_key) |
Returns the first element with key > elem_key |
C.equal_range
(elem_key) |
Returns the position of the
first element with key = = elem_key and the position of the last element with key = = to elem_key |
Operation |
Effect |
C.erase(elem_key) | Removes all elements having for
key elem_key and returns the number of removed elements |
C.erase(pos)
|
Removes the element at iterator
position pos and returns nothing |
Operation |
Effect |
C.[elem_key] | Returns a reference to the value
of the element with key elem_key if it exists, or inserts and element
with key elem_key if it exists |