GNU g++  v5.2.1
GNU Standard C++
forward_list.h File Reference

This is an internal header file, included by other library headers. More...

#include <initializer_list>
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator.h>
#include <bits/stl_algobase.h>
#include <bits/stl_function.h>
#include <bits/allocator.h>
#include <ext/alloc_traits.h>
#include <ext/aligned_buffer.h>
Include dependency graph for forward_list.h:

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers.

Do not attempt to use it directly. {forward_list}

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )

A helper basic node class for forward_list. This is just a linked list with nothing inside it. There are purely list shuffling utility methods here.

A helper node class for forward_list. This is just a linked list with uninitialized storage for a data value in each node. There is a sorting utility method.

A forward_list::iterator.

All the functions are op overloads.

A forward_list::const_iterator.

All the functions are op overloads.

Forward list iterator equality comparison.

Forward list iterator inequality comparison.

Base class for forward_list.

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

Template Parameters
_TpType of element.
_AllocAllocator type, defaults to allocator<_Tp>.

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.

Creates a forward_list with no elements.

Parameters
__alAn allocator object.

Copy constructor with allocator argument.

Parameters
__listInput list to copy.
__alAn allocator object.

Move constructor with allocator argument.

Parameters
__listInput list to move.
__alAn allocator object.

Creates a forward_list with default constructed elements.

Parameters
__nThe number of elements to initially create.

This constructor creates the forward_list with __n default constructed elements.

Creates a forward_list with copies of an exemplar element.

Parameters
__nThe number of elements to initially create.
__valueAn element to copy.
__alAn allocator object.

This constructor fills the forward_list with __n copies of __value.

Builds a forward_list from a range.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__alAn 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)).

The forward_list copy constructor.

Parameters
__listA forward_list of identical element and allocator types.

The forward_list move constructor.

Parameters
__listA forward_list of identical element and allocator types.

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

Builds a forward_list from an initializer_list

Parameters
__ilAn initializer_list of value_type.
__alAn allocator object.

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

The forward_list dtor.

The forward_list assignment operator.

Parameters
__listA 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.

The forward_list move assignment operator.

Parameters
__listA forward_list of identical element and allocator types.

The contents of __list are moved into this forward_list (without copying, if the allocators permit it). __list is a valid, but unspecified forward_list

The forward_list initializer list assignment operator.

Parameters
__ilAn 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().

Assigns a range to a forward_list.

Parameters
__firstAn input iterator.
__lastAn 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 number of elements of the resulting forward_list is the same as the number of elements assigned. Old data is lost.

Assigns a given value to a forward_list.

Parameters
__nNumber of elements to be assigned.
__valValue 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 has __n elements. Old data is lost.

Assigns an initializer_list to a forward_list.

Parameters
__ilAn 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().

Get a copy of the memory allocation object.

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

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

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

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

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

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

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

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

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

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

Returns the largest possible number of elements of forward_list.

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

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

Constructs object in forward_list at the front of the list.

Parameters
__argsArguments.

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.

Add data to the front of the forward_list.

Parameters
__valData 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.

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.

Constructs object in forward_list after the specified iterator.

Parameters
__posA const_iterator into the forward_list.
__argsArguments.
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.

Inserts given value into forward_list after specified iterator.

Parameters
__posAn iterator into the forward_list.
__valData 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.

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

Parameters
__posAn iterator into the forward_list.
__nNumber of elements to be inserted.
__valData to be inserted.
Returns
An iterator pointing to the last inserted copy of val or pos if n == 0.

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.

Inserts a range into the forward_list.

Parameters
__posAn iterator into the forward_list.
__firstAn input iterator.
__lastAn input iterator.
Returns
An iterator pointing to the last inserted element or __pos if __first == __last.

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.

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

Parameters
__posAn iterator into the forward_list.
__ilAn initializer_list of value_type.
Returns
An iterator pointing to the last inserted element or __pos if __il is empty.

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.

Removes the element pointed to by the iterator following pos.

Parameters
__posIterator pointing before element to be erased.
Returns
An iterator pointing to the element following the one that was erased, or end() if no such element exists.

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.

Remove a range of elements.

Parameters
__posIterator pointing before the first element to be erased.
__lastIterator pointing to one past the last element to be erased.
Returns
@ __last.

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.

Swaps data with another forward_list.

Parameters
__listA 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.

Resizes the forward_list to the specified number of elements.

Parameters
__szNumber 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 number of elements the forward_list is truncated, otherwise the forward_list is extended and the new elements are default constructed.

Resizes the forward_list to the specified number of elements.

Parameters
__szNumber of elements the forward_list should contain.
__valData 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 number of elements the forward_list is truncated, otherwise the forward_list is extended and new elements are populated with given data.

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.

Insert contents of another forward_list.

Parameters
__posIterator referencing the element to insert after.
__listSource list.

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

Requires this != x.

Insert element from another forward_list.

Parameters
__posIterator referencing the element to insert after.
__listSource list.
__iIterator 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.

Insert range from another forward_list.

Parameters
__posIterator referencing the element to insert after.
__listSource list.
__beforeIterator referencing before the start of range in list.
__lastIterator 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).

Remove all elements equal to value.

Parameters
__valThe value to remove.

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.

Remove all elements satisfying a predicate.

Parameters
__predUnary 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.

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.

Remove consecutive elements satisfying a predicate.

Parameters
__binary_predBinary 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.

Merge sorted lists.

Parameters
__listSorted 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.

Merge sorted lists according to comparison function.

Parameters
__listSorted list to merge.
__compComparison 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().

Sort the elements of the list.

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

Sort the forward_list using a comparison function.

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

Reverse the elements in list.

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

Forward list equality comparison.

Parameters
__lxA forward_list
__lyA forward_list of the same type as __lx.
Returns
True iff the elements of the forward lists are equal.

This is an equivalence relation. It is linear in the number of elements of the forward lists. Deques are considered equivalent if corresponding elements compare equal.

Forward list ordering relation.

Parameters
__lxA forward_list.
__lyA forward_list of the same type as __lx.
Returns
True iff __lx is lexicographically less than __ly.

This is a total ordering relation. It is linear in the number of elements of the forward lists. The elements must be comparable with <.

See std::lexicographical_compare() for how the determination is made.

Based on operator==

Based on operator<

Based on operator<

Based on operator<

See std::forward_list::swap().

References __catch, __throw_exception_again, __try, __gnu_cxx::__aligned_buffer< _Tp >::_M_ptr(), std::__exception_ptr::operator!=(), std::__exception_ptr::operator==(), __gnu_debug::operator>(), __gnu_debug::operator>=(), and std::__exception_ptr::swap().

Here is the call graph for this function: