# std::list< _Tp, _Alloc > Class Template Reference
[Containers, Sequences]

Inheritance diagram for std::list< _Tp, _Alloc >:

List of all members.

## Detailed Description

### template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
class std::list< _Tp, _Alloc >

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 407 of file stl_list.h.

## Public Types

- typedef _Alloc allocator_type
- typedef _List_const_iterator<
  _Tp > const_iterator
- typedef _Tp_alloc_type::const_pointer const_pointer
- typedef _Tp_alloc_type::const_reference const_reference
- typedef std::reverse_iterator<
  const_iterator > const_reverse_iterator
- typedef ptrdiff_t difference_type
- typedef _List_iterator< _Tp > iterator
- typedef _Tp_alloc_type::pointer pointer
- typedef _Tp_alloc_type::reference reference
- typedef std::reverse_iterator<
  iterator > reverse_iterator
- typedef size_t size_type
- typedef _Tp value_type

## Public Member Functions

- template<typename _InputIterator> void assign (_InputIterator __first, _InputIterator __last)
- void assign (size_type __n, const value_type &__val)
- const_reference back () const
- reference back ()
- const_iterator begin () const
- iterator begin ()
- void clear ()
- bool empty () const
- const_iterator end () const
- iterator end ()
- iterator erase (iterator __first, iterator __last)
- iterator erase (iterator __position)
- const_reference front () const
- reference front ()
- allocator_type get_allocator () const
- template<typename _InputIterator> void insert (iterator __position, _InputIterator __first, _InputIterator __last)
- void insert (iterator __position, size_type __n, const value_type &__x)
- iterator insert (iterator __position, const value_type &__x)
- template<typename _InputIterator> list (_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
- list (const list &__x)
- list (size_type __n, const value_type &__value=value_type(), const allocator_type &__a=allocator_type())
- list (const allocator_type &__a=allocator_type())
- size_type max_size () const
- template<typename _StrictWeakOrdering> void merge (list &, _StrictWeakOrdering)
- void merge (list &__x)
- list & operator= (const list &__x)
- void pop_back ()
- void pop_front ()
- void push_back (const value_type &__x)
- void push_front (const value_type &__x)
- const_reverse_iterator rbegin () const
- reverse_iterator rbegin ()
- void remove (const _Tp &__value)
- template<typename _Predicate> void remove_if (_Predicate)
- const_reverse_iterator rend () const
- reverse_iterator rend ()
- void resize (size_type __new_size, value_type __x=value_type())
- void reverse ()
- size_type size () const
- template<typename _StrictWeakOrdering> void sort (_StrictWeakOrdering)
- void sort ()
- void splice (iterator __position, list &__x, iterator __first, iterator __last)
- void splice (iterator __position, list &__x, iterator __i)
- void splice (iterator __position, list &__x)
- void swap (list &__x)
- template<typename _BinaryPredicate> void unique (_BinaryPredicate)
- void unique ()

## Protected Types

- typedef _List_node< _Tp > _Node
- typedef _Alloc::template rebind<
  _List_node< _Tp > >::other _Node_alloc_type

## Protected Member Functions

- template<typename _InputIterator> void _M_assign_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
- template<typename _Integer> void _M_assign_dispatch (_Integer __n, _Integer __val, __true_type)
- void _M_check_equal_allocators (list &__x)
- void _M_clear ()
- _Node * _M_create_node (const value_type &__x)
- void _M_erase (iterator __position)
- void _M_fill_assign (size_type __n, const value_type &__val)
- void _M_fill_initialize (size_type __n, const value_type &__x)
- _List_node< _Tp > * _M_get_node ()
- const _Node_alloc_type & _M_get_Node_allocator () const
- _Node_alloc_type & _M_get_Node_allocator ()
- _Tp_alloc_type _M_get_Tp_allocator () const
- void _M_init ()
- template<typename _InputIterator> void _M_initialize_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
- template<typename _Integer> void _M_initialize_dispatch (_Integer __n, _Integer __x, __true_type)
- void _M_insert (iterator __position, const value_type &__x)
- void _M_put_node (_List_node< _Tp > *__p)
- void _M_transfer (iterator __position, iterator __first, iterator __last)

## Protected Attributes

- _List_impl _M_impl

## Constructor & Destructor Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

std::list< _Tp, _Alloc >::list | ( | const allocator_type & | __a = `allocator_type()` | ) | `[inline, explicit]`

Default constructor creates no elements.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 472 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

std::list< _Tp, _Alloc >::list | ( | size_type | __n,
|  | const value_type & | __value = `value_type()`,
|  | const allocator_type & | __a = `allocator_type()` |
| ) |  |  | `[inline, explicit]`

Create a list with copies of an exemplar element.

Parameters:

  | n | The number of elements to initially create.
  | value | An element to copy.

This constructor fills the list with n copies of value.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 483 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

std::list< _Tp, _Alloc >::list | ( | const list< _Tp, _Alloc > & | __x | ) | `[inline]`

List copy constructor.

Parameters:

  | x | A list of identical element and allocator types.

The newly-created list uses a copy of the allocation object used by x.

Definition at line 495 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>

std::list< _Tp, _Alloc >::list | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | const allocator_type & | __a = `allocator_type()` |
| ) |  |  | `[inline]`

Builds a list from a range.

Parameters:

  | first | An input iterator.
  | last | An input iterator.

Create a list consisting of copies of the elements from [first,last). This is linear in N (where N is distance(first,last)).

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 509 of file stl_list.h.

## Member Function Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>

void std::list< _Tp, _Alloc >::assign | ( | _InputIterator | __first,
|  | _InputIterator | __last |
| ) |  |  | `[inline]`

Assigns a range to a list.

Parameters:

  | first | An input iterator.
  | last | An input iterator.

This function fills a list with copies of the elements in the range [first,last).

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 564 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::assign | ( | size_type | __n,
|  | const value_type & | __val |
| ) |  |  | `[inline]`

Assigns a given value to a list.

Parameters:

  | n | Number of elements to be assigned.
  | val | Value to be assigned.

This function fills a list with n copies of the given value. 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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 547 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_reference std::list< _Tp, _Alloc >::back | ( |  | ) | const`[inline]`

Returns a read-only (constant) reference to the data at the last element of the list.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 714 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

reference std::list< _Tp, _Alloc >::back | ( |  | ) | `[inline]`

Returns a read/write reference to the data at the last element of the list.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 702 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_iterator std::list< _Tp, _Alloc >::begin | ( |  | ) | const`[inline]`

Returns a read-only (constant) iterator that points to the first element in the list. Iteration is done in ordinary element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 591 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

iterator std::list< _Tp, _Alloc >::begin | ( |  | ) | `[inline]`

Returns a read/write iterator that points to the first element in the list. Iteration is done in ordinary element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 582 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::_M_assign_dispatch(), std::list< _Tp, _Alloc >::_M_fill_assign(), std::list< _Tp, _Allocator >::list(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::operator=(), std::operator==(), std::list< _Tp, _Alloc >::remove(), std::list< _Tp, _Alloc >::remove_if(), std::list< _Tp, _Alloc >::resize(), std::list< _Tp, _Alloc >::sort(), std::list< _Tp, _Allocator >::splice(), and std::list< _Tp, _Alloc >::unique().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::clear | ( |  | ) | `[inline]`

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 907 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

bool std::list< _Tp, _Alloc >::empty | ( |  | ) | const`[inline]`

Returns true if the list is empty. (Thus begin() would equal end().)

Definition at line 654 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::sort(), and std::list< _Tp, _Allocator >::splice().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_iterator std::list< _Tp, _Alloc >::end | ( |  | ) | const`[inline]`

Returns a read-only (constant) iterator that points one past the last element in the list. Iteration is done in ordinary element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 609 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

iterator std::list< _Tp, _Alloc >::end | ( |  | ) | `[inline]`

Returns a read/write iterator that points one past the last element in the list. Iteration is done in ordinary element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 600 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::_M_assign_dispatch(), std::list< _Tp, _Alloc >::_M_fill_assign(), std::list< _Tp, _Allocator >::list(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::operator=(), std::operator==(), std::list< _Tp, _Alloc >::remove(), std::list< _Tp, _Alloc >::remove_if(), std::list< _Tp, _Alloc >::resize(), std::list< _Tp, _Allocator >::splice(), and std::list< _Tp, _Alloc >::unique().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

iterator std::list< _Tp, _Alloc >::erase | ( | iterator | __first,
|  | iterator | __last |
| ) |  |  | `[inline]`

Remove a range of elements.

Parameters:

  | first | Iterator pointing to the first element to be erased.
  | last | Iterator pointing to one past the last element to be erased.

Returns:
  An iterator pointing to the element pointed to by last prior to erasing (or end()).

This function will erase the elements in the range [first,last) and shorten the list accordingly.

This operation is linear time in the size of the range 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 873 of file stl_list.h.

template<typename _Tp, typename _Alloc>

list< _Tp, _Alloc >::iterator std::list< _Tp, _Alloc >::erase | ( | iterator | __position | ) |

Remove element at given position.

Parameters:

  | position | Iterator pointing to element to be erased.

Returns:
  An iterator pointing to the next element (or end()).

This function will erase the element at the given position and thus shorten 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. 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 96 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_erase(), std::_List_node_base::_M_next, and std::_List_iterator< _Tp >::_M_node.

Referenced by std::list< _Tp, _Alloc >::_M_assign_dispatch(), std::list< _Tp, _Alloc >::_M_fill_assign(), std::list< _Tp, _Alloc >::operator=(), and std::list< _Tp, _Alloc >::resize().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_reference std::list< _Tp, _Alloc >::front | ( |  | ) | const`[inline]`

Returns a read-only (constant) reference to the data at the first element of the list.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 694 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

reference std::list< _Tp, _Alloc >::front | ( |  | ) | `[inline]`

Returns a read/write reference to the data at the first element of the list.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 686 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

allocator_type std::list< _Tp, _Alloc >::get_allocator | ( |  | ) | const`[inline]`

Get a copy of the memory allocation object.

Reimplemented from std::_List_base< _Tp, _Alloc >.

Definition at line 573 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>

void std::list< _Tp, _Alloc >::insert | ( | iterator | __position,
|  | _InputIterator | __first,
|  | _InputIterator | __last |
| ) |  |  | `[inline]`

Inserts a range into the list.

Parameters:

  | position | An iterator into the list.
  | first | An input iterator.
  | last | An input iterator.

This function will insert copies of the data in the range [first,last) into the list before the location specified by position.

This operation is linear in the number of elements inserted and does not invalidate iterators and references.

Definition at line 829 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::insert | ( | iterator | __position,
|  | size_type | __n,
|  | const value_type & | __x |
| ) |  |  | `[inline]`

Inserts a number of copies of given data into the list.

Parameters:

  | position | An iterator into the list.
  | n | Number of elements to be inserted.
  | x | Data to be inserted.

This function will insert a specified number of copies of the given data before the location specified by position.

This operation is linear in the number of elements inserted and does not invalidate iterators and references.

Definition at line 808 of file stl_list.h.

template<typename _Tp, typename _Alloc>

list< _Tp, _Alloc >::iterator std::list< _Tp, _Alloc >::insert | ( | iterator | __position,
|  | const value_type & | __x |
| ) |  |  |

Inserts given value into list before specified iterator.

Parameters:

  | position | An iterator into the list.
  | x | Data to be inserted.

Returns:
  An iterator that points to the inserted data.

This function will insert a copy of the given value before the specified location. 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 86 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_create_node(), std::_List_iterator< _Tp >::_M_node, and std::_List_node_base::hook().

Referenced by std::list< _Tp, _Alloc >::_M_assign_dispatch(), std::list< _Tp, _Alloc >::_M_fill_assign(), std::list< _Tp, _Alloc >::operator=(), and std::list< _Tp, _Alloc >::resize().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

size_type std::list< _Tp, _Alloc >::max_size | ( |  | ) | const`[inline]`

Returns the size() of the largest possible list.

Definition at line 664 of file stl_list.h.

template<typename _Tp, typename _Alloc>
template<typename _StrictWeakOrdering>

void std::list< _Tp, _Alloc >::merge | ( | list< _Tp, _Alloc > & | ,
|  | _StrictWeakOrdering |  |
| ) |  |  |

Merge sorted lists according to comparison function.

Parameters:

  | x | Sorted list to merge.
  | StrictWeakOrdering | Comparison function definining sort order.

Assumes that both x and this list are sorted according to StrictWeakOrdering. Merges elements of x into this list in sorted order, leaving x empty when complete. Elements in this list precede elements in x that are equivalent according to StrictWeakOrdering().

Definition at line 242 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_check_equal_allocators(), std::list< _Tp, _Alloc >::_M_transfer(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

template<typename _Tp, typename _Alloc>

void std::list< _Tp, _Alloc >::merge | ( | list< _Tp, _Alloc > & | __x | ) |

Merge sorted lists.

Parameters:

  | x | Sorted list to merge.

Assumes that both x and this list are sorted according to operator<(). Merges elements of x into this list in sorted order, leaving x empty when complete. Elements in this list precede elements in x that are equal.

Definition at line 212 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_check_equal_allocators(), std::list< _Tp, _Alloc >::_M_transfer(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

Referenced by std::list< _Tp, _Alloc >::sort().

template<typename _Tp, typename _Alloc>

list< _Tp, _Alloc > & std::list< _Tp, _Alloc >::operator= | ( | const list< _Tp, _Alloc > & | __x | ) |

List assignment operator.

Parameters:

  | x | A list of identical element and allocator types.

All the elements of x are copied, but unlike the copy constructor, the allocator object is not copied.

Definition at line 121 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), std::list< _Tp, _Alloc >::erase(), and std::list< _Tp, _Alloc >::insert().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::pop_back | ( |  | ) | `[inline]`

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 778 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::pop_front | ( |  | ) | `[inline]`

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 749 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::push_back | ( | const value_type & | __x | ) | `[inline]`

Add data to the end of the list.

Parameters:

  | x | Data to be added.

This is a typical stack operation. The function creates an element at the end of the list and assigns the given data to it. 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 763 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::push_front | ( | const value_type & | __x | ) | `[inline]`

Add data to the front of the list.

Parameters:

  | x | Data to be added.

This is a typical stack operation. The function creates an element at the front of the list and assigns the given data to it. 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 733 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_reverse_iterator std::list< _Tp, _Alloc >::rbegin | ( |  | ) | const`[inline]`

Returns a read-only (constant) reverse iterator that points to the last element in the list. Iteration is done in reverse element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 627 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

reverse_iterator std::list< _Tp, _Alloc >::rbegin | ( |  | ) | `[inline]`

Returns a read/write reverse iterator that points to the last element in the list. Iteration is done in reverse element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 618 of file stl_list.h.

template<typename _Tp, typename _Alloc>

void std::list< _Tp, _Alloc >::remove | ( | const _Tp & | __value | ) |

Remove all elements equal to value.

Parameters:

  | value | The value to remove.

Removes every element in the list equal to value. 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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 175 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_erase(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

template<typename _Tp, typename _Alloc>
template<typename _Predicate>

void std::list< _Tp, _Alloc >::remove_if | ( | _Predicate |  | ) |

Remove all elements satisfying a predicate.

Parameters:

  | Predicate | Unary predicate function or object.

Removes every element in the list for which the predicate returns true. 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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 309 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_erase(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

const_reverse_iterator std::list< _Tp, _Alloc >::rend | ( |  | ) | const`[inline]`

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 645 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

reverse_iterator std::list< _Tp, _Alloc >::rend | ( |  | ) | `[inline]`

Returns a read/write reverse iterator that points to one before the first element in the list. Iteration is done in reverse element order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 636 of file stl_list.h.

template<typename _Tp, typename _Alloc>

void std::list< _Tp, _Alloc >::resize | ( | size_type | __new_size,
|  | value_type | __x = `value_type()` |
| ) |  |  |

Resizes the list to the specified number of elements.

Parameters:

  | new_size | Number of elements the list should contain.
  | x | Data with which new elements should be populated.

This function will resize the list to the specified number of elements. If the number is smaller than the list's current size the list is truncated, otherwise the list is extended and new elements are populated with given data.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 106 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), std::list< _Tp, _Alloc >::erase(), and std::list< _Tp, _Alloc >::insert().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::reverse | ( |  | ) | `[inline]`

Reverse the elements in list.

Reverse the order of elements in the list in linear time.

Definition at line 1075 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

size_type std::list< _Tp, _Alloc >::size | ( |  | ) | const`[inline]`

Returns the number of elements in the list.

Definition at line 659 of file stl_list.h.

template<typename _Tp, typename _Alloc>
template<typename _StrictWeakOrdering>

void std::list< _Tp, _Alloc >::sort | ( | _StrictWeakOrdering |  | ) |

Sort the elements according to comparison function.

Sorts the elements of this list in NlogN time. Equivalent elements remain in list order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 348 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::empty(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::splice(), and std::list< _Tp, _Alloc >::swap().

template<typename _Tp, typename _Alloc>

void std::list< _Tp, _Alloc >::sort | ( |  | ) |

Sort the elements.

Sorts the elements of this list in NlogN time. Equivalent elements remain in list order.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 271 of file list.tcc.

References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::empty(), std::list< _Tp, _Alloc >::merge(), std::list< _Tp, _Alloc >::splice(), and std::list< _Tp, _Alloc >::swap().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::splice | ( | iterator | __position,
|  | list< _Tp, _Alloc > & | __x,
|  | iterator | __first,
|  | iterator | __last |
| ) |  |  | `[inline]`

Insert range from another list.

Parameters:

  | position | Iterator referencing the element to insert before.
  | x | Source list.
  | first | Iterator referencing the start of range in x.
  | last | Iterator referencing the end of range in x.

Removes elements in the range [first,last) and inserts them before position in constant time.

Undefined if position is in [first,last).

Definition at line 972 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::splice | ( | iterator | __position,
|  | list< _Tp, _Alloc > & | __x,
|  | iterator | __i |
| ) |  |  | `[inline]`

Insert element from another list.

Parameters:

  | position | Iterator referencing the element to insert before.
  | x | Source list.
  | i | Iterator referencing the element to move.

Removes the element in list x referenced by i and inserts it into the current list before position.

Definition at line 946 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::splice | ( | iterator | __position,
|  | list< _Tp, _Alloc > & | __x |
| ) |  |  | `[inline]`

Insert contents of another list.

Parameters:

  | position | Iterator referencing the element to insert before.
  | x | Source list.

The elements of x are inserted in constant time in front of the element referenced by position. x becomes an empty list.

Requires this != x.

Definition at line 926 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::sort().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>

void std::list< _Tp, _Alloc >::swap | ( | list< _Tp, _Alloc > & | __x | ) | `[inline]`

Swaps data with another list.

Parameters:

  | x | A list of the same element and allocator types.

This exchanges the elements between two lists in constant time. Note that the global std::swap() function is specialized such that std::swap(l1,l2) will feed to this function.

Definition at line 890 of file stl_list.h.

Referenced by std::list< _Tp, _Alloc >::sort(), and std::swap().

template<typename _Tp, typename _Alloc>
template<typename _BinaryPredicate>

void std::list< _Tp, _Alloc >::unique | ( | _BinaryPredicate |  | ) |

Remove consecutive elements satisfying a predicate.

Parameters:

  | BinaryPredicate | Binary predicate function or object.

For each consecutive set of elements [first,last) that satisfy predicate(first,i) where i is an iterator in [first,last), 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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 327 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_erase(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

template<typename _Tp, typename _Alloc>

void std::list< _Tp, _Alloc >::unique | ( |  | ) |

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.

Reimplemented in std::__debug::list< _Tp, _Allocator >.

Definition at line 192 of file list.tcc.

References std::list< _Tp, _Alloc >::_M_erase(), std::list< _Tp, _Alloc >::begin(), and std::list< _Tp, _Alloc >::end().

The documentation for this class was generated from the following files:

- stl_list.h
- list.tcc