#include <stl_list.h>
Inheritance diagram for std::list< Type, Alloc >:
Public Member Functions | |
list (const allocator_type &a=allocator_type()) | |
Default constructor creates no elements. | |
list (size_type n, const value_type &value, const allocator_type &a=allocator_type()) | |
Create a list with copies of an exemplar element. | |
list (size_type n) | |
Create a list with default elements. | |
list (const list &x) | |
List copy constructor. | |
template<typename InputIterator> | list (InputIterator first, InputIterator last, const allocator_type &a=allocator_type()) |
Builds a list from a range. | |
list & | operator= (const list &x) |
List assignment operator. | |
void | assign (size_type n, const value_type &__val) |
Assigns a given value to a list. | |
template<typename InputIterator> void | assign (InputIterator first, InputIterator last) |
Assigns a range to a list. | |
allocator_type | get_allocator () const |
Get a copy of the memory allocation object. | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
bool | empty () const |
size_type | size () const |
size_type | max_size () const |
void | resize (size_type new_size, const value_type &x) |
Resizes the list to the specified number of elements. | |
void | resize (size_type new_size) |
Resizes the list to the specified number of elements. | |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
void | push_front (const value_type &x) |
Add data to the front of the list. | |
void | pop_front () |
Removes first element. | |
void | push_back (const value_type &x) |
Add data to the end of the list. | |
void | pop_back () |
Removes last element. | |
iterator | insert (iterator position, const value_type &x) |
Inserts given value into list before specified iterator. | |
void | insert (iterator position, size_type n, const value_type &x) |
Inserts a number of copies of given data into the list. | |
template<typename InputIterator> void | insert (iterator position, InputIterator first, InputIterator last) |
Inserts a range into the list. | |
iterator | erase (iterator position) |
Remove element at given position. | |
iterator | erase (iterator first, iterator last) |
Remove a range of elements. | |
void | swap (list &x) |
Swaps data with another list. | |
void | clear () |
void | splice (iterator position, list &x) |
Insert contents of another list. | |
void | splice (iterator position, list &, iterator __i) |
Insert element from another list. | |
void | splice (iterator position, list &, iterator first, iterator last) |
Insert range from another list. | |
void | remove (const Type &value) |
Remove all elements equal to value. | |
template<typename Predicate> void | remove_if (Predicate) |
Remove all elements satisfying a predicate. | |
void | unique () |
Remove consecutive duplicate elements. | |
template<typename BinaryPredicate> void | unique (BinaryPredicate) |
Remove consecutive elements satisfying a predicate. | |
void | merge (list &x) |
Merge sorted lists. | |
template<typename StrictWeakOrdering> void | merge (list &, StrictWeakOrdering) |
Merge sorted lists according to comparison function. | |
void | reverse () |
Reverse the elements in list. | |
void | sort () |
Sort the elements. | |
template<typename StrictWeakOrdering> void | sort (StrictWeakOrdering) |
Sort the elements according to comparison function. |
Meets the requirements of a container, a reversible container, and a sequence, including the optional sequence requirements with the exception of at
and operator
[].
This is a doubly linked list. Traversal up and down the list requires linear time, but adding and removing elements (or nodes) is done in constant time, regardless of where the change takes place. Unlike std::vector and std::deque, random-access iterators are not provided, so subscripting ( [] ) access is not allowed. For algorithms which only need sequential access, this lack makes no difference.
Also unlike the other standard containers, std::list provides specialized algorithms unique to linked lists, such as splicing, sorting, and in-place reversal.
Definition at line 387 of file stl_list.h.
|
Default constructor creates no elements. Definition at line 475 of file stl_list.h. |
|
Create a list with copies of an exemplar element.
|
|
Create a list with default elements.
|
|
List copy constructor.
|
|
Builds a list from a range.
|
|
Assigns a range to a list.
Note that the assignment completely changes the list and that the resulting list's size is the same as the number of elements assigned. Old data may be lost. Definition at line 579 of file stl_list.h. |
|
Assigns a given value to a list.
|
|
Returns a read-only (constant) reference to the data at the last element of the list. Definition at line 737 of file stl_list.h. |
|
Returns a read/write reference to the data at the last element of the list. Definition at line 729 of file stl_list.h. |
|
Returns a read-only (constant) iterator that points to the first element in the list. Iteration is done in ordinary element order. Definition at line 606 of file stl_list.h. |
|
Returns a read/write iterator that points to the first element in the list. Iteration is done in ordinary element order. Definition at line 597 of file stl_list.h. Referenced by std::list< Type, Allocator >::list(), std::list< Type, Alloc >::merge(), std::list< Type, Alloc >::operator=(), std::operator==(), std::list< Type, Alloc >::remove_if(), std::list< Type, Alloc >::resize(), std::list< Type, Alloc >::sort(), std::list< Type, Allocator >::splice(), and std::list< Type, Alloc >::unique(). |
|
Erases all the elements. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty. Definition at line 920 of file stl_list.h. |
|
Returns true if the list is empty. (Thus begin() would equal end().) Definition at line 668 of file stl_list.h. Referenced by std::list< Type, Alloc >::sort(), and std::list< Type, Allocator >::splice(). |
|
Returns a read-only (constant) iterator that points one past the last element in the list. Iteration is done in ordinary element order. Definition at line 623 of file stl_list.h. |
|
Returns a read/write iterator that points one past the last element in the list. Iteration is done in ordinary element order. Definition at line 615 of file stl_list.h. Referenced by std::list< Type, Allocator >::list(), std::list< Type, Alloc >::merge(), std::list< Type, Alloc >::operator=(), std::operator==(), std::list< Type, Alloc >::remove_if(), std::list< Type, Alloc >::resize(), std::list< Type, Allocator >::splice(), and std::list< Type, Alloc >::unique(). |
|
Remove a range of elements.
Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed. The user is also cautioned that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty. Definition at line 893 of file stl_list.h. |
|
Remove element at given position.
Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed. The user is also cautioned that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty. Definition at line 95 of file list.tcc. Referenced by std::list< Type, Alloc >::operator=(), and std::list< Type, Alloc >::resize(). |
|
Returns a read-only (constant) reference to the data at the first element of the list. Definition at line 721 of file stl_list.h. |
|
Returns a read/write reference to the data at the first element of the list. Definition at line 713 of file stl_list.h. |
|
Get a copy of the memory allocation object. Definition at line 588 of file stl_list.h. |
|
Inserts a range into the list.
Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references. Definition at line 847 of file stl_list.h. |
|
Inserts a number of copies of given data into the list.
Due to the nature of a list this operation can be done in constant time, and does not invalidate iterators and references. Definition at line 828 of file stl_list.h. |
|
Inserts given value into list before specified iterator.
Referenced by std::list< Type, Alloc >::operator=(), and std::list< Type, Alloc >::resize(). |
|
Returns the size() of the largest possible list. Definition at line 678 of file stl_list.h. |
|
Merge sorted lists according to comparison function.
References std::list< Type, Alloc >::begin(), and std::list< Type, Alloc >::end(). |
|
Merge sorted lists.
References std::list< Type, Alloc >::begin(), and std::list< Type, Alloc >::end(). Referenced by std::list< Type, Alloc >::sort(). |
|
List assignment operator.
References std::list< Type, Alloc >::begin(), std::list< Type, Alloc >::end(), std::list< Type, Alloc >::erase(), and std::list< Type, Alloc >::insert(). |
|
Removes last element. This is a typical stack operation. It shrinks the list by one. Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed. Note that no data is returned, and if the last element's data is needed, it should be retrieved before pop_back() is called. Definition at line 797 of file stl_list.h. |
|
Removes first element. This is a typical stack operation. It shrinks the list by one. Due to the nature of a list this operation can be done in constant time, and only invalidates iterators/references to the element being removed. Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop_front() is called. Definition at line 768 of file stl_list.h. |
|
Add data to the end of the list.
|
|
Add data to the front of the list.
|
|
Returns a read-only (constant) reverse iterator that points to the last element in the list. Iteration is done in reverse element order. Definition at line 641 of file stl_list.h. |
|
Returns a read/write reverse iterator that points to the last element in the list. Iteration is done in reverse element order. Definition at line 632 of file stl_list.h. |
|
Remove all elements equal to value.
|
|
Remove all elements satisfying a predicate.
References std::list< Type, Alloc >::begin(), and std::list< Type, Alloc >::end(). |
|
Returns a read-only (constant) reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order. Definition at line 659 of file stl_list.h. |
|
Returns a read/write reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order. Definition at line 650 of file stl_list.h. |
|
Resizes the list to the specified number of elements.
|
|
Resizes the list to the specified number of elements.
References std::list< Type, Alloc >::begin(), std::list< Type, Alloc >::end(), std::list< Type, Alloc >::erase(), and std::list< Type, Alloc >::insert(). |
|
Reverse the elements in list. Reverse the order of elements in the list in linear time. Definition at line 1073 of file stl_list.h. |
|
Returns the number of elements in the list. Definition at line 673 of file stl_list.h. |
|
Sort the elements according to comparison function. Sorts the elements of this list in NlogN time. Equivalent elements remain in list order. Definition at line 341 of file list.tcc. References std::list< Type, Alloc >::begin(), std::list< Type, Alloc >::empty(), std::list< Type, Alloc >::merge(), std::list< Type, Alloc >::splice(), and std::list< Type, Alloc >::swap(). |
|
Sort the elements. Sorts the elements of this list in NlogN time. Equivalent elements remain in list order. Definition at line 237 of file list.tcc. References std::list< Type, Alloc >::begin(), std::list< Type, Alloc >::empty(), std::list< Type, Alloc >::merge(), std::list< Type, Alloc >::splice(), and std::list< Type, Alloc >::swap(). |
|
Insert range from another list.
Undefined if position is in [first,last). Definition at line 975 of file stl_list.h. |
|
Insert element from another list.
|
|
Insert contents of another list.
Referenced by std::list< Type, Alloc >::sort(). |
|
Swaps data with another list.
Referenced by std::list< Type, Alloc >::sort(), and std::swap(). |
|
Remove consecutive elements satisfying a predicate.
References std::list< Type, Alloc >::begin(), and std::list< Type, Alloc >::end(). |
|
Remove consecutive duplicate elements. For each consecutive set of elements with the same value, remove all but the first one. Remaining elements stay in list order. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty. Definition at line 190 of file list.tcc. References std::list< Type, Alloc >::begin(), and std::list< Type, Alloc >::end(). |