std::forward_list(3)

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

SYNOPSIS

Inherits _Fwd_list_base< _Tp, _Alloc >.

  Public Types
typedef _Alloc allocator_type
typedef _Base::const_iterator const_iterator
typedef _Tp_alloc_type::const_pointer const_pointer
typedef _Tp_alloc_type::const_reference const_reference
typedef std::ptrdiff_t difference_type
typedef _Base::iterator iterator
typedef _Tp_alloc_type::pointer pointer
typedef _Tp_alloc_type::reference reference
typedef std::size_t size_type
typedef _Tp value_type

  Public Member Functions
void assign (std::initializer_list< _Tp > __il)
void assign (size_type __n, const _Tp &__val)
template<typename _InputIterator > void assign (_InputIterator __first, _InputIterator __last)
const_iterator before_begin () const
iterator before_begin ()
const_iterator begin () const
iterator begin ()
const_iterator cbefore_begin () const
const_iterator cbegin () const
const_iterator cend () const
void clear ()
template<typename... _Args> iterator emplace_after (const_iterator __pos, _Args &&...__args)
template<typename... _Args> void emplace_front (_Args &&...__args)
bool empty () const
const_iterator end () const
iterator end ()
iterator erase_after (const_iterator __pos, iterator __last)
iterator erase_after (const_iterator __pos)
forward_list (std::initializer_list< _Tp > __il, const _Alloc &__al=_Alloc())
forward_list (forward_list &&__list)
forward_list (const forward_list &__list)
template<typename _InputIterator > forward_list (_InputIterator __first, _InputIterator __last, const _Alloc &__al=_Alloc())
forward_list (size_type __n, const _Tp &__value, const _Alloc &__al=_Alloc())
forward_list (size_type __n)
forward_list (forward_list &&__list, const _Alloc &__al)
forward_list (const forward_list &__list, const _Alloc &__al)
forward_list (const _Alloc &__al=_Alloc())
const_reference front () const
reference front ()
allocator_type get_allocator () const
void insert_after (const_iterator __pos, std::initializer_list< _Tp > __il)
template<typename _InputIterator > void insert_after (const_iterator __pos, _InputIterator __first, _InputIterator __last)
void insert_after (const_iterator __pos, size_type __n, const _Tp &__val)
iterator insert_after (const_iterator __pos, _Tp &&__val)
iterator insert_after (const_iterator __pos, const _Tp &__val)
size_type max_size () const
template<typename _Comp > void merge (forward_list &&__list, _Comp __comp)
void merge (forward_list &&__list)
forward_list & operator= (std::initializer_list< _Tp > __il)
forward_list & operator= (forward_list &&__list)
forward_list & operator= (const forward_list &__list)
void pop_front ()
void push_front (_Tp &&__val)
void push_front (const _Tp &__val)
void remove (const _Tp &__val)
template<typename _Pred > void remove_if (_Pred __pred)
void resize (size_type __sz, value_type __val)
void resize (size_type __sz)
void reverse ()
template<typename _Comp > void sort (_Comp __comp)
void sort ()
void splice_after (const_iterator __pos, forward_list &&__list, const_iterator __before, const_iterator __last)
void splice_after (const_iterator __pos, forward_list &&__list, const_iterator __it)
void splice_after (const_iterator __pos, forward_list &&__list)
void swap (forward_list &&__list)
template<typename _BinPred > void unique (_BinPred __binary_pred)
void unique ()
~forward_list ()

  Private Types
typedef _Alloc::template rebind< _Fwd_list_node< _Tp, _Tp_alloc_type >>::other _Node_alloc_type;struct _Fwd_list_impl:public _Node_alloc_type{_Fwd_list_node_base< _Tp_alloc_type > _M_head;_Fwd_list_impl():_Node_alloc_type(), _M_head(){}_Fwd_list_impl(const _Node_alloc_type &__a):_Node_alloc_type(__a), _M_head(){}};_Fwd_list_impl _M_impl;public:typedef _Fwd_list_iterator< _Tp, _Tp_alloc_type > iterator;typedef _Fwd_list_const_iterator< _Tp, _Tp_alloc_type > const_iterator;typedef _Fwd_list_node< _Tp, _Tp_alloc_type > _Node;typedef _Fwd_list_node_base< _Tp_alloc_type > _Node_base;_Node_alloc_type &_M_get_Node_allocator(){return *static_cast< _Node_alloc_type * > &this->_M_impl);}const _Node_alloc_type &_M_get_Node_allocator() const {return *static_cast< const _Node_alloc_type * > &this-> _M_impl

  Private Member Functions
_Node::_Pointer _M_create_node (_Args &&...__args)
_Node_base::_Pointer _M_erase_after (typename _Node_base::_Pointer __pos, typename _Node_base::_Pointer __last)
_Node_base::_Pointer _M_erase_after (typename _Node_base::_Pointer __pos)
_Node::_Pointer _M_get_node ()
_Node_base::_Pointer _M_insert_after (const_iterator __pos, _Args &&...__args)
void _M_put_node (typename _Node::_Pointer __p)

Detailed Description

  template<typename _Tp, typename _Alloc = allocator<_Tp>> class std::forward_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 sequence, including the optional sequence requirements with the exception of at and operator[].

This is a singly linked list. Traversal up 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::forward_list provides specialized algorithms unique to linked lists, such as splicing, sorting, and in-place reversal.

A couple points on memory allocation for forward_list<Tp>:

First, we never actually allocate a Tp, we allocate Fwd_list_node<Tp>'s and trust [20.1.5]/4 to DTRT. This is to ensure that after elements from forward_list<X,Alloc1> are spliced into forward_list<X,Alloc2>, destroying the memory of the second list is a valid operation, i.e., Alloc1 giveth and Alloc2 taketh away.

Definition at line 402 of file forward_list.h.

Constructor & Destructor Documentation

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (const _Alloc & __al = _Alloc()) [inline, explicit]

Creates a forward_list with no elements.

Parameters:
    al An allocator object.

Definition at line 431 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (const forward_list< _Tp, _Alloc > & __list, const _Alloc & __al) [inline]

Copy constructor with allocator argument.

Parameters:
    list Input list to copy.
    al An allocator object.

Definition at line 440 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (forward_list< _Tp, _Alloc > && __list, const _Alloc & __al) [inline]

Move constructor with allocator argument.

Parameters:
    list Input list to move.
    al An allocator object.

Definition at line 449 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (size_type __n) [inline, explicit]

Creates a forward_list with copies of the default element type.

Parameters:
    n The number of elements to initially create.

This constructor fills the forward_list with n copies of the default value.

Definition at line 462 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (size_type __n, const _Tp & __value, const _Alloc & __al = _Alloc()) [inline]

Creates a forward_list with copies of an exemplar element.

Parameters:
    n The number of elements to initially create.
    value An element to copy.
    al An allocator object.

This constructor fills the forward_list with n copies of value.

Definition at line 475 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename _InputIterator > std::forward_list< _Tp, _Alloc >::forward_list (_InputIterator __first, _InputIterator __last, const _Alloc & __al = _Alloc()) [inline]

Builds a forward_list from a range.

Parameters:
    first An input iterator.
    last An input iterator.
    al An allocator object.

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

Definition at line 491 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (const forward_list< _Tp, _Alloc > & __list) [inline]

The forward_list copy constructor.

Parameters:
    list A forward_list of identical element and allocator types.

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

Definition at line 508 of file forward_list.h.

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

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (forward_list< _Tp, _Alloc > && __list) [inline]

The forward_list move constructor.

Parameters:
    list A forward_list of identical element and allocator types.

The newly-created forward_list contains the exact contents of forward_list. The contents of list are a valid, but unspecified forward_list.

Definition at line 521 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::forward_list (std::initializer_list< _Tp > __il, const _Alloc & __al = _Alloc()) [inline]

Builds a forward_list from an initializer_list.

Parameters:
    il An initializer_list of value_type.
    al An allocator object.

Create a forward_list consisting of copies of the elements in the initializer_list il. This is linear in il.size().

Definition at line 532 of file forward_list.h.

References std::initializer_list< _E >::begin(), and std::initializer_list< _E >::end().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> std::forward_list< _Tp, _Alloc >::~forward_list () [inline]

The forward_list dtor.

Definition at line 540 of file forward_list.h.

Member Function Documentation

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::assign (std::initializer_list< _Tp > __il) [inline]

Assigns an initializer_list to a forward_list.

Parameters:
    il An initializer_list of value_type.

Replace the contents of the forward_list with copies of the elements in the initializer_list il. This is linear in il.size().

Definition at line 635 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::assign (size_type __n, const _Tp & __val) [inline]

Assigns a given value to a forward_list.

Parameters:
    n Number of elements to be assigned.
    val Value to be assigned.

This function fills a forward_list with n copies of the given value. Note that the assignment completely changes the forward_list and that the resulting forward_list's size is the same as the number of elements assigned. Old data may be lost.

Definition at line 620 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename _InputIterator > void std::forward_list< _Tp, _Alloc >::assign (_InputIterator __first, _InputIterator __last) [inline]

Assigns a range to a forward_list.

Parameters:
    first An input iterator.
    last An input iterator.

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

Note that the assignment completely changes the forward_list and that the resulting forward_list's size is the same as the number of elements assigned. Old data may be lost.

Definition at line 603 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::before_begin () const [inline]

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

Definition at line 662 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::before_begin () [inline]

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

Definition at line 653 of file forward_list.h.

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

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::begin () const [inline]

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

Definition at line 679 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::begin () [inline]

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

Definition at line 670 of file forward_list.h.

Referenced by std::forward_list< _Tp, _Alloc >::forward_list(), std::forward_list< _Tp, _Alloc >::operator=(), and std::forward_list< _Tp, _Alloc >::unique().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::cbefore_begin () const [inline]

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

Definition at line 715 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::cbegin () const [inline]

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

Definition at line 706 of file forward_list.h.

Referenced by std::forward_list< _Tp, _Alloc >::operator=(), and std::operator==().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::cend () const [inline]

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

Definition at line 724 of file forward_list.h.

Referenced by std::forward_list< _Tp, _Alloc >::operator=(), and std::operator==().

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

Definition at line 1033 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename... _Args> iterator std::forward_list< _Tp, _Alloc >::emplace_after (const_iterator __pos, _Args &&... __args) [inline]

Constructs object in forward_list after the specified iterator.

Parameters:
    pos A const_iterator into the forward_list.
    args Arguments.

Returns:
    An iterator that points to the inserted data.

This function will insert an object of type T constructed with T(std::forward<Args>(args)...) after the specified location. Due to the nature of a forward_list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 839 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename... _Args> void std::forward_list< _Tp, _Alloc >::emplace_front (_Args &&... __args) [inline]

Constructs object in forward_list at the front of the list.

Parameters:
    args Arguments.

This function will insert an object of type Tp constructed with Tp(std::forward<Args>(args)...) at the front of the list Due to the nature of a forward_list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 783 of file forward_list.h.

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

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

Definition at line 732 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_iterator std::forward_list< _Tp, _Alloc >::end () const [inline]

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

Definition at line 697 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::end () [inline]

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

Definition at line 688 of file forward_list.h.

Referenced by std::forward_list< _Tp, _Alloc >::forward_list(), std::forward_list< _Tp, _Alloc >::operator=(), std::forward_list< _Tp, _Alloc >::resize(), and std::forward_list< _Tp, _Alloc >::unique().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::erase_after (const_iterator __pos, iterator __last) [inline]

Remove a range of elements.

Parameters:
    pos Iterator pointing before 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 (pos,last) and shorten the forward_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 responsibility.

Definition at line 974 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::erase_after (const_iterator __pos) [inline]

Removes the element pointed to by the iterator following pos.

Parameters:
    pos 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 forward_list by one.

Due to the nature of a forward_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 responsibility.

Definition at line 945 of file forward_list.h.

Referenced by std::forward_list< _Tp, _Alloc >::operator=(), std::forward_list< _Tp, _Alloc >::resize(), and std::forward_list< _Tp, _Alloc >::unique().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> const_reference std::forward_list< _Tp, _Alloc >::front () const [inline]

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

Definition at line 761 of file forward_list.h.

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

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

Definition at line 749 of file forward_list.h.

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

Get a copy of the memory allocation object.

Definition at line 643 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::insert_after (const_iterator __pos, std::initializer_list< _Tp > __il) [inline]

Inserts the contents of an initializer_list into forward_list after the specified iterator.

Parameters:
    pos An iterator into the forward_list.
    il An initializer_list of value_type.

This function will insert copies of the data in the initializer_list il into the forward_list before the location specified by pos.

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

Definition at line 922 of file forward_list.h.

References std::move().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename _InputIterator > void std::forward_list< _Tp, _Alloc >::insert_after (const_iterator __pos, _InputIterator __first, _InputIterator __last) [inline]

Inserts a range into the forward_list.

Parameters:
    position An iterator into the forward_list.
    first An input iterator.
    last An input iterator.

This function will insert copies of the data in the range [first,last) into the forward_list after the location specified by pos.

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

Definition at line 901 of file forward_list.h.

References std::move().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::insert_after (const_iterator __pos, size_type __n, const _Tp & __val) [inline]

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

Parameters:
    pos An iterator into the forward_list.
    n Number of elements to be inserted.
    val Data to be inserted.

This function will insert a specified number of copies of the given data after the location specified by pos.

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

Definition at line 880 of file forward_list.h.

References std::move().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> iterator std::forward_list< _Tp, _Alloc >::insert_after (const_iterator __pos, const _Tp & __val) [inline]

Inserts given value into forward_list after specified iterator.

Parameters:
    pos An iterator into the forward_list.
    val Data to be inserted.

Returns:
    An iterator that points to the inserted data.

This function will insert a copy of the given value after the specified location. Due to the nature of a forward_list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 856 of file forward_list.h.

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

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

Returns the largest possible size of forward_list.

Definition at line 739 of file forward_list.h.

  template<typename _Tp , typename _Alloc > template<typename _Comp > void std::forward_list< _Tp, _Alloc >::merge (forward_list< _Tp, _Alloc > && __list, _Comp __comp) [inline]

Merge sorted lists according to comparison function.

Parameters:
    list Sorted list to merge.
    comp Comparison function defining sort order.

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

Definition at line 438 of file forward_list.tcc.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::merge (forward_list< _Tp, _Alloc > && __list) [inline]

Merge sorted lists.

Parameters:
    list Sorted list to merge.

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

Definition at line 1153 of file forward_list.h.

References std::forward_list< _Tp, _Alloc >::merge().

Referenced by std::forward_list< _Tp, _Alloc >::merge().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> forward_list& std::forward_list< _Tp, _Alloc >::operator= (std::initializer_list< _Tp > __il) [inline]

The forward_list initializer list assignment operator.

Parameters:
    il An initializer_list of value_type.

Replace the contents of the forward_list with copies of the elements in the initializer_list il. This is linear in il.size().

Definition at line 583 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> forward_list& std::forward_list< _Tp, _Alloc >::operator= (forward_list< _Tp, _Alloc > && __list) [inline]

The forward_list move assignment operator.

Parameters:
    list A forward_list of identical element and allocator types.

The contents of list are moved into this forward_list (without copying). list is a valid, but unspecified forward_list

Definition at line 564 of file forward_list.h.

  template<typename _Tp , typename _Alloc > forward_list< _Tp, _Alloc > & std::forward_list< _Tp, _Alloc >::operator= (const forward_list< _Tp, _Alloc > & __list) [inline]

The forward_list assignment operator.

Parameters:
    list A forward_list of identical element and allocator types.

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

Definition at line 298 of file forward_list.tcc.

References std::forward_list< _Tp, _Alloc >::before_begin(), std::forward_list< _Tp, _Alloc >::begin(), std::forward_list< _Tp, _Alloc >::cbegin(), std::forward_list< _Tp, _Alloc >::cend(), std::forward_list< _Tp, _Alloc >::end(), std::forward_list< _Tp, _Alloc >::erase_after(), and std::forward_list< _Tp, _Alloc >::insert_after().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::pop_front () [inline]

Removes first element.

This is a typical stack operation. It shrinks the forward_list by one. Due to the nature of a forward_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 821 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::push_front (const _Tp & __val) [inline]

Add data to the front of the forward_list.

Parameters:
    val Data to be added.

This is a typical stack operation. The function creates an element at the front of the forward_list and assigns the given data to it. Due to the nature of a forward_list this operation can be done in constant time, and does not invalidate iterators and references.

Definition at line 798 of file forward_list.h.

  template<typename _Tp , typename _Alloc > void std::forward_list< _Tp, _Alloc >::remove (const _Tp & __val) [inline]

Remove all elements equal to value.

Parameters:
    val 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 responsibility.

Definition at line 377 of file forward_list.tcc.

  template<typename _Tp , typename _Alloc > template<typename _Pred > void std::forward_list< _Tp, _Alloc >::remove_if (_Pred __pred) [inline]

Remove all elements satisfying a predicate.

Parameters:
    pred 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 responsibility.

Definition at line 397 of file forward_list.tcc.

  template<typename _Tp , typename _Alloc > void std::forward_list< _Tp, _Alloc >::resize (size_type __sz, value_type __val) [inline]

Resizes the forward_list to the specified number of elements.

Parameters:
    sz Number of elements the forward_list should contain.
    val Data with which new elements should be populated.

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

Definition at line 325 of file forward_list.tcc.

References std::forward_list< _Tp, _Alloc >::before_begin(), std::forward_list< _Tp, _Alloc >::end(), std::forward_list< _Tp, _Alloc >::erase_after(), and std::forward_list< _Tp, _Alloc >::insert_after().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::resize (size_type __sz) [inline]

Resizes the forward_list to the specified number of elements.

Parameters:
    sz Number of elements the forward_list should contain.

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

Definition at line 1006 of file forward_list.h.

References std::forward_list< _Tp, _Alloc >::resize().

Referenced by std::forward_list< _Tp, _Alloc >::resize().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::reverse () [inline]

Reverse the elements in list.

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

Definition at line 1204 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> template<typename _Comp > void std::forward_list< _Tp, _Alloc >::sort (_Comp __comp) [inline]

Sort the forward_list using a comparison function.

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

Definition at line 1192 of file forward_list.h.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::sort () [inline]

Sort the elements of the list.

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

Definition at line 1178 of file forward_list.h.

  template<typename _Tp , typename _Alloc > void std::forward_list< _Tp, _Alloc >::splice_after (const_iterator __pos, forward_list< _Tp, _Alloc > && __list, const_iterator __before, const_iterator __last) [inline]

Insert range from another forward_list.

Parameters:
    pos Iterator referencing the element to insert after.
    list Source list.
    before Iterator referencing before the start of range in list.
    last Iterator referencing the end of range in list.

Removes elements in the range (before,last) and inserts them after pos in constant time.

Undefined if pos is in (before,last).

Definition at line 361 of file forward_list.tcc.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::splice_after (const_iterator __pos, forward_list< _Tp, _Alloc > && __list, const_iterator __it) [inline]

Insert element from another forward_list.

Parameters:
    pos Iterator referencing the element to insert after.
    list Source list.
    it Iterator referencing the element before the element to move.

Removes the element in list list referenced by i and inserts it into the current list after pos.

Definition at line 1063 of file forward_list.h.

References std::forward_list< _Tp, _Alloc >::splice_after().

Referenced by std::forward_list< _Tp, _Alloc >::splice_after().

  template<typename _Tp , typename _Alloc > void std::forward_list< _Tp, _Alloc >::splice_after (const_iterator __pos, forward_list< _Tp, _Alloc > && __list) [inline]

Insert contents of another forward_list.

Parameters:
    pos Iterator referencing the element to insert after.
    list Source list.

The elements of list are inserted in constant time after the element referenced by pos. list becomes an empty list.

Requires this != x.

Definition at line 344 of file forward_list.tcc.

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::swap (forward_list< _Tp, _Alloc > && __list) [inline]

Swaps data with another forward_list.

Parameters:
    list A forward_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 991 of file forward_list.h.

Referenced by std::swap().

  template<typename _Tp , typename _Alloc > template<typename _BinPred > void std::forward_list< _Tp, _Alloc >::unique (_BinPred __binary_pred) [inline]

Remove consecutive elements satisfying a predicate.

Parameters:
    binary_pred 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 responsibility.

Definition at line 417 of file forward_list.tcc.

References std::forward_list< _Tp, _Alloc >::begin(), std::forward_list< _Tp, _Alloc >::end(), and std::forward_list< _Tp, _Alloc >::erase_after().

  template<typename _Tp, typename _Alloc = allocator<_Tp>> void std::forward_list< _Tp, _Alloc >::unique () [inline]

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 responsibility.

Definition at line 1124 of file forward_list.h.

References std::forward_list< _Tp, _Alloc >::unique().

Referenced by std::forward_list< _Tp, _Alloc >::unique().

Author

Generated automatically by Doxygen for libstdc++ from the source code.