Container Flashcards
the library of pair
include<utility></utility>
pair declaration
pair<F, S> newPair (newPair is the pair’s name)
create a pair with the specified first and second values, and how to access them
make_pair() ; name’s pair.first, name’s pair.second
declare a pair playAttempts with an integer as the first element and a double as the second element
pair<int, double> playAttempts;
the library of list
include <list></list>
list declaration
list<T> newList;</T>
push_back()
adds an element to the end of the list
push_front()
adds an element to the front of the list
front
returns the front element of the list
back()
return the back element (last element) of the list
pop_back, pop_front
removes element from the end of the list, from the front of the list
remove
remove all the occurrences in the list
how to declare the iterator in the list
list<T>:: iterator iter;</T>
insert
insert(iteratorPosition, newElement) -> insert newElement into the list before the iteratorPosition
erase
erase(iteratorPosition) - removes a single element at iteratorPosition
erase(iteratorFirst, iteratorLast) - removes a range of elements from iteratorFirst(inclusive) to iteratorLast(exclusive)