9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 #include #include #include #include #include #include #include using namespace std; // begin(): Returns a random-access iterator to the first element in the container. // end(): Returns a random-access iterator that point just beyond the end of // the list. // rbegin() Returns an iterator to the first element in a reversed list. // rend() Returns an iterator to the end of a reversed list. // back(): Returns a reference to the last element of the list. // front() Returns a reference to the first element in a list. // pop_back() Deletes the element at the end of the list. // pop_front() Deletes the element at the front of the list. // push_back() Add an element to the end of the list. // push_front() Add an element to the front of the list. // clear(): Erases the elements of the list. // empty(): Tests if the list container is empty. // erase() Removes an element or a range of elements in a list from specified positions. // insert() Inserts an element or a number of elements into the list at a specified position. // size() Returns the number of elements in the list. // max_size() Returns the maximum length of the list. // resize() Specifies a new size for a list. // capacity(): Returns the number of elements that the list could contain without allocating more storage. // reserve() Reserves a minimum length of storage for a list object. // remove() Erases elements in a list that match a specified value. // remove_if() Erases elements from the list for which a specified predicate is satisfied. // sort() Arranges the elements of a list in ascending order or with respect to some other order relation. // unique() Removes adjacent duplicate elements or adjacent elements that satisfy some other binary predicate from the list. int main() { // Adding then removing from a container. list l; for ( int i = 0; i < 10; ++i ) {l.push_back( i ); // append l.push_front( i ); // insert in front } while ( ! l.empty() ) { // Prints/pops oldest (head) element first, cout << l.front() << endl; l.pop_front(); } }