_GLIBCXX_STD::list< _Tp, _Alloc > Class Template Reference

A standard container with linear time access to elements, and fixed time insertion/deletion at any point in the sequence. More...

#include <stl_list.h>

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

_GLIBCXX_STD::_List_base< _Tp, _Alloc > List of all members.

Public Types

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

Public Member Functions

 list (const allocator_type &__a=allocator_type())
 Default constructor creates no elements.
 list (size_type __n, const value_type &__value=value_type(), const allocator_type &__a=allocator_type())
 Create a list with copies of an exemplar element.
 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.
listoperator= (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, value_type __x=value_type())
 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 _Tp &__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.

Protected Types

typedef _List_node< _Tp > _Node

Protected Member Functions

_Node_M_create_node (const value_type &__x)
template<typename _Integer>
void _M_assign_dispatch (_Integer __n, _Integer __val, __true_type)
template<typename _InputIterator>
void _M_assign_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
void _M_fill_assign (size_type __n, const value_type &__val)
template<typename _Integer>
void _M_insert_dispatch (iterator __pos, _Integer __n, _Integer __x, __true_type)
template<typename _InputIterator>
void _M_insert_dispatch (iterator __pos, _InputIterator __first, _InputIterator __last, __false_type)
void _M_fill_insert (iterator __pos, size_type __n, const value_type &__x)
void _M_transfer (iterator __position, iterator __first, iterator __last)
void _M_insert (iterator __position, const value_type &__x)
void _M_erase (iterator __position)

Private Types

typedef _Alloc::value_type _Alloc_value_type
typedef _Base::_Tp_alloc_type _Tp_alloc_type

Private Member Functions

 __glibcxx_class_requires (_Tp, _SGIAssignableConcept) __glibcxx_class_requires2(_Tp

Private Attributes

 _Alloc_value_type
_SameTypeConcept typedef _List_base<
_Tp, _Alloc > 
_Base

Detailed Description

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

A standard container with linear time access to elements, and fixed time insertion/deletion at any point in the sequence.

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


Member Typedef Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Alloc::value_type _GLIBCXX_STD::list< _Tp, _Alloc >::_Alloc_value_type [private]

Definition at line 401 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _List_node<_Tp> _GLIBCXX_STD::list< _Tp, _Alloc >::_Node [protected]

Definition at line 425 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Base::_Tp_alloc_type _GLIBCXX_STD::list< _Tp, _Alloc >::_Tp_alloc_type [private]

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

Definition at line 406 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Alloc _GLIBCXX_STD::list< _Tp, _Alloc >::allocator_type

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

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 420 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _List_const_iterator<_Tp> _GLIBCXX_STD::list< _Tp, _Alloc >::const_iterator

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 415 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_type::const_pointer _GLIBCXX_STD::list< _Tp, _Alloc >::const_pointer

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 411 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_type::const_reference _GLIBCXX_STD::list< _Tp, _Alloc >::const_reference

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 413 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef std::reverse_iterator<const_iterator> _GLIBCXX_STD::list< _Tp, _Alloc >::const_reverse_iterator

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 416 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef ptrdiff_t _GLIBCXX_STD::list< _Tp, _Alloc >::difference_type

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 419 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _List_iterator<_Tp> _GLIBCXX_STD::list< _Tp, _Alloc >::iterator

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 414 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_type::pointer _GLIBCXX_STD::list< _Tp, _Alloc >::pointer

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 410 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Tp_alloc_type::reference _GLIBCXX_STD::list< _Tp, _Alloc >::reference

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 412 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef std::reverse_iterator<iterator> _GLIBCXX_STD::list< _Tp, _Alloc >::reverse_iterator

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 417 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef size_t _GLIBCXX_STD::list< _Tp, _Alloc >::size_type

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 418 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
typedef _Tp _GLIBCXX_STD::list< _Tp, _Alloc >::value_type

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 409 of file stl_list.h.


Constructor & Destructor Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_GLIBCXX_STD::list< _Tp, _Alloc >::list ( const allocator_type __a = allocator_type()  )  [inline, explicit]

Default constructor creates no elements.

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 468 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_GLIBCXX_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.

Definition at line 479 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_GLIBCXX_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 491 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>
_GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 510 of file stl_list.h.


Member Function Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_GLIBCXX_STD::list< _Tp, _Alloc >::__glibcxx_class_requires ( _Tp  ,
_SGIAssignableConcept   
) [private]

template<typename _Tp, typename _Alloc>
template<typename _InputIterator>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_assign_dispatch ( _InputIterator  __first,
_InputIterator  __last,
__false_type   
) [protected]

Definition at line 157 of file list.tcc.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _Integer>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_assign_dispatch ( _Integer  __n,
_Integer  __val,
__true_type   
) [inline, protected]

Definition at line 1079 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::assign().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_Node* _GLIBCXX_STD::list< _Tp, _Alloc >::_M_create_node ( const value_type __x  )  [inline, protected]

Definition at line 446 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::_M_insert(), and _GLIBCXX_STD::list< _Tp, _Alloc >::insert().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_erase ( iterator  __position  )  [inline, protected]

Definition at line 1145 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Alloc >::erase(), _GLIBCXX_STD::list< _Tp, _Allocator >::pop_back(), _GLIBCXX_STD::list< _Tp, _Allocator >::pop_front(), _GLIBCXX_STD::list< _Tp, _Alloc >::remove(), _GLIBCXX_STD::list< _Tp, _Alloc >::remove_if(), and _GLIBCXX_STD::list< _Tp, _Alloc >::unique().

template<typename _Tp, typename _Alloc>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_fill_assign ( size_type  __n,
const value_type __val 
) [protected]

Definition at line 142 of file list.tcc.

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

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::_M_assign_dispatch(), and _GLIBCXX_STD::list< _Tp, _Allocator >::assign().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_fill_insert ( iterator  __pos,
size_type  __n,
const value_type __x 
) [inline, protected]

Definition at line 1123 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::_M_insert_dispatch(), and _GLIBCXX_STD::list< _Tp, _Allocator >::insert().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_insert ( iterator  __position,
const value_type __x 
) [inline, protected]

Definition at line 1137 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::_M_fill_insert(), _GLIBCXX_STD::list< _Tp, _Allocator >::_M_insert_dispatch(), _GLIBCXX_STD::list< _Tp, _Allocator >::push_back(), and _GLIBCXX_STD::list< _Tp, _Allocator >::push_front().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_insert_dispatch ( iterator  __pos,
_InputIterator  __first,
_InputIterator  __last,
__false_type   
) [inline, protected]

Definition at line 1112 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _Integer>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_insert_dispatch ( iterator  __pos,
_Integer  __n,
_Integer  __x,
__true_type   
) [inline, protected]

Definition at line 1102 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Allocator >::insert().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::_M_transfer ( iterator  __position,
iterator  __first,
iterator  __last 
) [inline, protected]

Definition at line 1132 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Alloc >::merge(), and _GLIBCXX_STD::list< _Tp, _Allocator >::splice().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 561 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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.

Definition at line 544 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_reference _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 711 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
reference _GLIBCXX_STD::list< _Tp, _Alloc >::back (  )  [inline]

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

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 699 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 588 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 579 of file stl_list.h.

Referenced by _GLIBCXX_STD::list< _Tp, _Alloc >::_M_assign_dispatch(), _GLIBCXX_STD::list< _Tp, _Alloc >::_M_fill_assign(), _GLIBCXX_STD::list< _Tp, _Allocator >::front(), _GLIBCXX_STD::list< _Tp, _Allocator >::list(), _GLIBCXX_STD::list< _Tp, _Alloc >::merge(), _GLIBCXX_STD::list< _Tp, _Alloc >::operator=(), _GLIBCXX_STD::operator==(), _GLIBCXX_STD::list< _Tp, _Allocator >::pop_front(), _GLIBCXX_STD::list< _Tp, _Allocator >::push_front(), _GLIBCXX_STD::list< _Tp, _Alloc >::remove(), _GLIBCXX_STD::list< _Tp, _Alloc >::remove_if(), _GLIBCXX_STD::list< _Tp, _Allocator >::rend(), _GLIBCXX_STD::list< _Tp, _Alloc >::resize(), _GLIBCXX_STD::list< _Tp, _Allocator >::size(), _GLIBCXX_STD::list< _Tp, _Alloc >::sort(), _GLIBCXX_STD::list< _Tp, _Allocator >::splice(), and _GLIBCXX_STD::list< _Tp, _Alloc >::unique().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 898 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
bool _GLIBCXX_STD::list< _Tp, _Alloc >::empty (  )  const [inline]

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

Definition at line 651 of file stl_list.h.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 606 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 597 of file stl_list.h.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
iterator _GLIBCXX_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.

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

template<typename _Tp, typename _Alloc>
list< _Tp, _Alloc >::iterator _GLIBCXX_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 95 of file list.tcc.

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

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_reference _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 691 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
reference _GLIBCXX_STD::list< _Tp, _Alloc >::front (  )  [inline]

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

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 683 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
allocator_type _GLIBCXX_STD::list< _Tp, _Alloc >::get_allocator (  )  const [inline]

Get a copy of the memory allocation object.

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

Definition at line 570 of file stl_list.h.

Referenced by __gnu_debug_def::list< _Tp, _Allocator >::splice().

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator>
void _GLIBCXX_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.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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.

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

template<typename _Tp, typename _Alloc>
list< _Tp, _Alloc >::iterator _GLIBCXX_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 85 of file list.tcc.

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

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
size_type _GLIBCXX_STD::list< _Tp, _Alloc >::max_size (  )  const [inline]

Returns the size() of the largest possible list.

Definition at line 661 of file stl_list.h.

template<typename _Tp, typename _Alloc>
template<typename _StrictWeakOrdering>
void _GLIBCXX_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 315 of file list.tcc.

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

template<typename _Tp, typename _Alloc>
void _GLIBCXX_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 211 of file list.tcc.

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

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

template<typename _Tp, typename _Alloc>
list< _Tp, _Alloc > & _GLIBCXX_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 120 of file list.tcc.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 775 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 746 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 760 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 730 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 624 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
reverse_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 615 of file stl_list.h.

template<typename _Tp, typename _Alloc>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 174 of file list.tcc.

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

template<typename _Tp, typename _Alloc>
template<typename _Predicate>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 276 of file list.tcc.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 642 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
reverse_iterator _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 633 of file stl_list.h.

template<typename _Tp, typename _Alloc>
void _GLIBCXX_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.

Definition at line 105 of file list.tcc.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 1051 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
size_type _GLIBCXX_STD::list< _Tp, _Alloc >::size (  )  const [inline]

Returns the number of elements in the list.

Definition at line 656 of file stl_list.h.

template<typename _Tp, typename _Alloc>
template<typename _StrictWeakOrdering>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 343 of file list.tcc.

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

template<typename _Tp, typename _Alloc>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 238 of file list.tcc.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::splice ( iterator  __position,
list< _Tp, _Alloc > &  ,
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 953 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_STD::list< _Tp, _Alloc >::splice ( iterator  __position,
list< _Tp, _Alloc > &  ,
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 931 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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.

Definition at line 915 of file stl_list.h.

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

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void _GLIBCXX_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 888 of file stl_list.h.

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

template<typename _Tp, typename _Alloc>
template<typename _BinaryPredicate>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 294 of file list.tcc.

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

template<typename _Tp, typename _Alloc>
void _GLIBCXX_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 __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 191 of file list.tcc.

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


Member Data Documentation

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_GLIBCXX_STD::list< _Tp, _Alloc >::_Alloc_value_type [private]

Definition at line 403 of file stl_list.h.

template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
_SameTypeConcept typedef _List_base<_Tp, _Alloc> _GLIBCXX_STD::list< _Tp, _Alloc >::_Base [private]

Reimplemented in __gnu_debug_def::list< _Tp, _Allocator >.

Definition at line 403 of file stl_list.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 16:58:22 2010 for GNU C++ STL by  doxygen 1.4.7