Inherits std::_Fwd_list_base< _Tp, _Alloc >.
typedef _Alloc allocator_type
typedef _Fwd_list_const_iterator< _Tp > const_iterator
typedef _Alloc_traits::const_pointer const_pointer
typedef const value_type & const_reference
typedef std::ptrdiff_t difference_type
typedef _Fwd_list_iterator< _Tp > iterator
typedef _Alloc_traits::pointer pointer
typedef value_type & reference
typedef std::size_t size_type
typedef _Tp value_type
forward_list ()=default
Creates a forward_list with no elements.
forward_list (const _Alloc &__al) noexcept
Creates a forward_list with no elements.
forward_list (const forward_list &__list, const _Alloc &__al)
Copy constructor with allocator argument.
forward_list (forward_list &&__list, const _Alloc &__al) noexcept(_Node_alloc_traits::_S_always_equal())
Move constructor with allocator argument.
forward_list (size_type __n, const _Alloc &__al=_Alloc())
Creates a forward_list with default constructed elements.
forward_list (size_type __n, const _Tp &__value, const _Alloc &__al=_Alloc())
Creates a forward_list with copies of an exemplar element.
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> forward_list (_InputIterator __first, _InputIterator __last, const _Alloc &__al=_Alloc())
Builds a forward_list from a range.
forward_list (const forward_list &__list)
The forward_list copy constructor.
forward_list (forward_list &&)=default
The forward_list move constructor.
forward_list (std::initializer_list< _Tp > __il, const _Alloc &__al=_Alloc())
Builds a forward_list from an initializer_list.
~forward_list () noexcept
The forward_list dtor.
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> void assign (_InputIterator __first, _InputIterator __last)
Assigns a range to a forward_list.
void assign (size_type __n, const _Tp &__val)
Assigns a given value to a forward_list.
void assign (std::initializer_list< _Tp > __il)
Assigns an initializer_list to a forward_list.
iterator before_begin () noexcept
const_iterator before_begin () const noexcept
iterator begin () noexcept
const_iterator begin () const noexcept
const_iterator cbefore_begin () const noexcept
const_iterator cbegin () const noexcept
const_iterator cend () const noexcept
void clear () noexcept
Erases all the elements.
template<typename... _Args> iterator emplace_after (const_iterator __pos, _Args &&... __args)
Constructs object in forward_list after the specified iterator.
template<typename... _Args> void emplace_front (_Args &&... __args)
Constructs object in forward_list at the front of the list.
bool empty () const noexcept
iterator end () noexcept
const_iterator end () const noexcept
iterator erase_after (const_iterator __pos)
Removes the element pointed to by the iterator following pos.
iterator erase_after (const_iterator __pos, const_iterator __last)
Remove a range of elements.
reference front ()
const_reference front () const
allocator_type get_allocator () const noexcept
Get a copy of the memory allocation object.
iterator insert_after (const_iterator __pos, const _Tp &__val)
Inserts given value into forward_list after specified iterator.
iterator insert_after (const_iterator __pos, _Tp &&__val)
iterator insert_after (const_iterator __pos, size_type __n, const _Tp &__val)
Inserts a number of copies of given data into the forward_list.
template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> iterator insert_after (const_iterator __pos, _InputIterator __first, _InputIterator __last)
Inserts a range into the forward_list.
iterator insert_after (const_iterator __pos, std::initializer_list< _Tp > __il)
Inserts the contents of an initializer_list into forward_list after the specified iterator.
size_type max_size () const noexcept
void merge (forward_list &&__list)
Merge sorted lists.
void merge (forward_list &__list)
template<typename _Comp > void merge (forward_list &&__list, _Comp __comp)
Merge sorted lists according to comparison function.
template<typename _Comp > void merge (forward_list &__list, _Comp __comp)
forward_list & operator= (const forward_list &__list)
The forward_list assignment operator.
forward_list & operator= (forward_list &&__list) noexcept(_Node_alloc_traits::_S_nothrow_move())
The forward_list move assignment operator.
forward_list & operator= (std::initializer_list< _Tp > __il)
The forward_list initializer list assignment operator.
void pop_front ()
Removes first element.
void push_front (const _Tp &__val)
Add data to the front of the forward_list.
void push_front (_Tp &&__val)
void remove (const _Tp &__val)
Remove all elements equal to value.
template<typename _Pred > void remove_if (_Pred __pred)
Remove all elements satisfying a predicate.
void resize (size_type __sz)
Resizes the forward_list to the specified number of elements.
void resize (size_type __sz, const value_type &__val)
Resizes the forward_list to the specified number of elements.
void reverse () noexcept
Reverse the elements in list.
void sort ()
Sort the elements of the list.
template<typename _Comp > void sort (_Comp __comp)
Sort the forward_list using a comparison function.
void splice_after (const_iterator __pos, forward_list &&__list) noexcept
Insert contents of another forward_list.
void splice_after (const_iterator __pos, forward_list &__list) noexcept
void splice_after (const_iterator __pos, forward_list &&__list, const_iterator __i) noexcept
Insert element from another forward_list.
void splice_after (const_iterator __pos, forward_list &__list, const_iterator __i) noexcept
void swap (forward_list &__list) noexcept
Swaps data with another forward_list.
void unique ()
Remove consecutive duplicate elements.
template<typename _BinPred > void unique (_BinPred __binary_pred)
Remove consecutive elements satisfying a predicate.
void splice_after (const_iterator __pos, forward_list &&, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
void splice_after (const_iterator __pos, forward_list &, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
template<typename... _Args> _Node * _M_create_node (_Args &&... __args)
_Fwd_list_node_base * _M_erase_after (_Fwd_list_node_base *__pos)
_Fwd_list_node_base * _M_erase_after (_Fwd_list_node_base *__pos, _Fwd_list_node_base *__last)
_Node * _M_get_node ()
_Node_alloc_type & _M_get_Node_allocator () noexcept
const _Node_alloc_type & _M_get_Node_allocator () const noexcept
template<typename... _Args> _Fwd_list_node_base * _M_insert_after (const_iterator __pos, _Args &&... __args)
void _M_put_node (_Node *__p)
Template Parameters:
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.
Definition at line 425 of file forward_list.h.
Creates a forward_list with no elements.
Creates a forward_list with no elements.
Parameters:
Definition at line 468 of file forward_list.h.
Copy constructor with allocator argument.
Parameters:
Definition at line 477 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::begin(), and std::forward_list< _Tp, _Alloc >::end().
Move constructor with allocator argument.
Parameters:
Definition at line 505 of file forward_list.h.
Creates a forward_list with default constructed elements.
Parameters:
This constructor creates the forward_list with __n default constructed elements.
Definition at line 520 of file forward_list.h.
Creates a forward_list with copies of an exemplar element.
Parameters:
This constructor fills the forward_list with __n copies of __value.
Definition at line 533 of file forward_list.h.
Builds a forward_list from a range.
Parameters:
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 550 of file forward_list.h.
The forward_list copy constructor.
Parameters:
Definition at line 560 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::begin(), and std::forward_list< _Tp, _Alloc >::end().
The forward_list move constructor.
Parameters:
The newly-created forward_list contains the exact contents of the moved instance. The contents of the moved instance are a valid, but unspecified forward_list.
Builds a forward_list from an initializer_list.
Parameters:
Create a forward_list consisting of copies of the elements in the initializer_list __il. This is linear in __il.size().
Definition at line 584 of file forward_list.h.
The forward_list dtor.
Definition at line 592 of file forward_list.h.
Assigns a range to a forward_list.
Parameters:
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 number of elements of the resulting forward_list is the same as the number of elements assigned.
Definition at line 660 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::assign(), and std::forward_list< _Tp, _Alloc >::operator=().
Assigns a given value to a forward_list.
Parameters:
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 has __n elements.
Definition at line 677 of file forward_list.h.
Assigns an initializer_list to a forward_list.
Parameters:
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 689 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::assign().
Definition at line 704 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::insert_after().
Definition at line 713 of file forward_list.h.
Definition at line 721 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::forward_list().
Definition at line 730 of file forward_list.h.
Definition at line 766 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::emplace_front().
Definition at line 757 of file forward_list.h.
Referenced by std::operator<(), and std::forward_list< _Tp, _Alloc >::operator=().
Definition at line 775 of file forward_list.h.
Referenced by std::operator<(), and std::forward_list< _Tp, _Alloc >::operator=().
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 1088 of file forward_list.h.
Constructs object in forward_list after the specified iterator.
Parameters:
Returns:
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 897 of file forward_list.h.
Constructs object in forward_list at the front of the list.
Parameters:
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 836 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::cbefore_begin(), and std::forward_list< _Tp, _Alloc >::front().
Definition at line 783 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::insert_after().
Definition at line 739 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::forward_list(), and std::forward_list< _Tp, _Alloc >::insert_after().
Definition at line 748 of file forward_list.h.
Removes the element pointed to by the iterator following pos.
Parameters:
Returns:
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 1000 of file forward_list.h.
Remove a range of elements.
Parameters:
Returns:
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 1023 of file forward_list.h.
Definition at line 800 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::emplace_front().
Definition at line 811 of file forward_list.h.
Get a copy of the memory allocation object.
Definition at line 694 of file forward_list.h.
Inserts given value into forward_list after specified iterator.
Parameters:
Returns:
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 914 of file forward_list.h.
Referenced by std::forward_list< _Tp, _Alloc >::insert_after().
Inserts a number of copies of given data into the forward_list.
Parameters:
Returns:
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 256 of file forward_list.tcc.
Inserts a range into the forward_list.
Parameters:
Returns:
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 271 of file forward_list.tcc.
References std::forward_list< _Tp, _Alloc >::before_begin(), std::forward_list< _Tp, _Alloc >::empty(), and std::forward_list< _Tp, _Alloc >::end().
Inserts the contents of an initializer_list into forward_list after the specified iterator.
Parameters:
Returns:
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 979 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::insert_after().
Definition at line 790 of file forward_list.h.
References std::allocator_traits< _Alloc >::max_size().
Merge sorted lists.
Parameters:
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 1228 of file forward_list.h.
Merge sorted lists according to comparison function.
Parameters:
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 349 of file forward_list.tcc.
The forward_list assignment operator.
Parameters:
All the elements of __list are copied.
Whether the allocator is copied depends on the allocator traits.
Definition at line 140 of file forward_list.tcc.
References std::__addressof(), std::forward_list< _Tp, _Alloc >::cbegin(), and std::forward_list< _Tp, _Alloc >::cend().
The forward_list move assignment operator.
Parameters:
The contents of __list are moved into this forward_list (without copying, if the allocators permit it).
Afterwards __list is a valid, but unspecified forward_list
Whether the allocator is moved depends on the allocator traits.
Definition at line 620 of file forward_list.h.
The forward_list initializer list assignment operator.
Parameters:
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 639 of file forward_list.h.
References std::forward_list< _Tp, _Alloc >::assign().
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 879 of file forward_list.h.
Add data to the front of the forward_list.
Parameters:
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 856 of file forward_list.h.
Remove all elements equal to value.
Parameters:
Removes every element in the list equal to __val. 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 284 of file forward_list.tcc.
Remove all elements satisfying a predicate.
Parameters:
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 312 of file forward_list.tcc.
Resizes the forward_list to the specified number of elements.
Parameters:
This function will resize the forward_list to the specified number of elements. If the number is smaller than the forward_list's current number of elements the forward_list is truncated, otherwise the forward_list is extended and the new elements are default constructed.
Definition at line 182 of file forward_list.tcc.
Resizes the forward_list to the specified number of elements.
Parameters:
This function will resize the forward_list to the specified number of elements. If the number is smaller than the forward_list's current number of elements the forward_list is truncated, otherwise the forward_list is extended and new elements are populated with given data.
Definition at line 201 of file forward_list.tcc.
Reverse the elements in list. Reverse the order of elements in the list in linear time.
Definition at line 1281 of file forward_list.h.
Sort the elements of the list. Sorts the elements of this list in NlogN time. Equivalent elements remain in list order.
Definition at line 1262 of file forward_list.h.
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 393 of file forward_list.tcc.
Insert contents of another forward_list.
Parameters:
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 1105 of file forward_list.h.
Insert element from another forward_list.
Parameters:
Removes the element in list list referenced by i and inserts it into the current list after pos.
Definition at line 239 of file forward_list.tcc.
Insert range from another forward_list.
Parameters:
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 1149 of file forward_list.h.
Insert range from another forward_list.
Parameters:
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 1154 of file forward_list.h.
Swaps data with another forward_list.
Parameters:
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.
Whether the allocators are swapped depends on the allocator traits.
Definition at line 1042 of file forward_list.h.
Referenced by std::__profile::swap(), and std::__debug::swap().
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 1199 of file forward_list.h.
Remove consecutive elements satisfying a predicate.
Parameters:
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 328 of file forward_list.tcc.
References std::begin(), and std::end().
Generated automatically by Doxygen for libstdc++ from the source code.