C++ Library - <forward_list>

forward_list is a popularly used sequence container. Container is an object that holds data of same type. forward_list container is implemented as singly linked-list, hence it provides unidirectional sequential access to it's data.
forward_list doesn't provide fast random access, it only supports sequential access in only one directions. forward_list allows insertion and deletion operation anywhere within a sequence in constant time.
Elements of forward_list can be scattered in different chunks of memory. Container stores necessary information to allow sequential access to it's data. forward_lists can shrink or expand as needed from both ends at run time. The storage requirement is fulfilled automatically by internal allocator.
Zero sized forward_lists are also valid. In that case forward_list.begin() and forward_list.end() points to same location. But behavior of calling front() is undefined.
Below is definition of std::forward_list from <forward_list> header file
template < class T, class Alloc = allocator<T> > class forward_list;
T − Type of the element contained.
T may be substituted by any other data type including user-defined type.
T − Type of the element contained.
T may be substituted by any other data type including user-defined type.
Alloc − Type of allocator object.
By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Alloc − Type of allocator object.
By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Following member types can be used as parameters or return type by member functions.
Below is list of all methods from <forward_list> header.
Constructs an empty forward_list with zero elements.
Constructs a new forward_list with n elements and assigns val to each element of forward_list.
Constructs a new forward_list with n elements and assign zero value to each element of forward_list.
Constructs a forward_list with as many elements as in range of first to last.
Constructs a forward_list with copy of each elements present in existing list.
Constructs a forward_list with the contents of other using move semantics.
Constructs a forward_list from initialize list.
Destroys forward_list object by deallocating it's memory.
Assigns new value to forward_list by replacing old ones.
Assigns new values to forward_list by replacing old ones.
Assigns new values to forward_list by replacing old ones.
Returns a random access iterator which points to the position before the first element of the forward_list.
Returns a random access iterator which points to the first element of the forward_list.
Returns a constant random access iterator which points to the position before the first element of the forward_list.
Returns a constant random access iterator which points to the beginning of the forward_list.
Returns a constant random access iterator which points to the end of the forward_list.
Destroys the forward_list by removing all elements from the forward_list and sets size of forward_list to zero.
Constructs and inserts new element after position in the forward_list and increases size of forward_list by one.
Inserts new element at the beginning of the forward_list and increases size of forward_list by one.
Tests whether forward_list is empty or not.
Returns a random access iterator which points to the last element of the forward_list.
Removes single element after position from the the forward_list.
Removes range of element from the the forward_list.
Returns a reference to the first element of the forward_list.
Returns an allocator associated with forward_list
Extends iterator by inserting new element after position in forward_list
Extends iterator by inserting new element after position in forward_list
Extends iterator by inserting new element after position in forward_list
Extends iterator by inserting new element after position in forward_list
Extends iterator by inserting new element after position in forward_list
Returns the maximum number of elements can be held by forward_list.
Merges two sorted forward_lists into one.
Merges two sorted forward_lists into one.
Merges two sorted forward_lists into one.
Merges two sorted forward_lists into one by using move semantics.
Assigns new contents to the forward_list by replacing old ones.
Assign new contents to the forward_list by replacing old ones.
Assign new contents to the forward_list by replacing old ones.
Removes first element from forward_list.
Inserts new element at the beginning of forward_list.
Inserts new element at the beginning of forward_list.
removes element(s) from the forward_list that matches the value.
removes elements from the forward_list that fulfills the condition.
Changes the size of forward_list.
Changes the size of forward_list.
Reverses the order of the elements present in the forward_list.
Sorts the elements of the forward_list.
Sorts the elements of the forward_list.
Transfers all elements from forward_list to *this.
Transfers all elements from forward_list x to *this by using move semantics.
Transfers a element pointed to by iterator i from forward_list x into *this.
Transfers the element pointed to by iterator i from forward_list x into *this by using move semantics.
Transfers the elements in the range of first to last from x to *this.
Transfers the elements in the range of first to last from x to *this by using move semantics.
Exchanges the content of a forward_list with contents of another forward_list x.
Removes all consecutive duplicate elements from the forward_list.
Removes all consecutive duplicate elements from the forward_list.
Tests whether two forward_lists are equal or not.
Tests whether two forward_lists are equal or not.
Tests whether first forward_list is less than other or not.
Tests whether first forward_list is less than or equal to other or not.
Tests whether first forward_list is greater than other or not.
Tests whether first forward_list is greater than or equal to other or not.
Exchanges the contents of two forward_list.
 Print
 Add Notes
 Bookmark this page