list Class
The STL list class is a template class of sequence containers that maintain their elements in a linear arrangement and allow efficient insertions and deletions at any location within the sequence. The sequence is stored as a bidirectional linked list of elements, each containing a member of some type Type.
template <
class Type,
class Allocator=allocator<Type>
>
class list
Parameters
Type
The element data type to be stored in the list.Allocator
The type that represents the stored allocator object that encapsulates details about the list's allocation and deallocation of memory. This argument is optional, and the default value is allocator<Type>.
Remarks
The choice of container type should be based in general on the type of searching and inserting required by the application. Vectors should be the preferred container for managing a sequence when random access to any element is at a premium and insertions or deletions of elements are only required at the end of a sequence. The performance of the class deque container is superior when random access is needed and insertions and deletions at both the beginning and the end of a sequence are at a premium.
The list member functions merge, reverse, unique, remove, and remove_if have been optimized for operation on list objects and offer a high-performance alternative to their generic counterparts.
List reallocation occurs when a member function must insert or erase elements of the list. In all such cases, only iterators or references that point at erased portions of the controlled sequence become invalid.
Include the STL standard header <list> to define the container template class list and several supporting templates.
Constructors
Constructs a list of a specific size or with elements of a specific value or with a specific allocator or as a copy of some other list. |
Typedefs
A type that represents the allocator class for a list object. |
|
A type that provides a bidirectional iterator that can read a const element in a list. |
|
A type that provides a pointer to a const element in a list. |
|
A type that provides a reference to a const element stored in a list for reading and performing const operations. |
|
A type that provides a bidirectional iterator that can read any const element in a list. |
|
A type that provides the difference between two iterators that refer to elements within the same list. |
|
A type that provides a bidirectional iterator that can read or modify any element in a list. |
|
A type that provides a pointer to an element in a list. |
|
A type that provides a reference to a const element stored in a list for reading and performing const operations. |
|
A type that provides a bidirectional iterator that can read or modify an element in a reversed list. |
|
A type that counts the number of elements in a list. |
|
A type that represents the data type stored in a list. |
Member Functions
Erases elements from a list and copies a new set of elements to the target list. |
|
Returns a reference to the last element of a list. |
|
Returns an iterator addressing the first element in a list. |
|
Returns a const iterator addressing the first element in a list. |
|
Returns a const iterator that addresses the location succeeding the last element in a list. |
|
Erases all the elements of a list. |
|
Returns a const iterator addressing the first element in a reversed list. |
|
Returns a const iterator that addresses the location succeeding the last element in a reversed list. |
|
Inserts an element constructed in place into a list at a specified position. |
|
Adds an element constructed in place to the end of a list. |
|
Adds an element constructed in place to the beginning of a list. |
|
Tests if a list is empty. |
|
Returns an iterator that addresses the location succeeding the last element in a list. |
|
Removes an element or a range of elements in a list from specified positions. |
|
Returns a reference to the first element in a list. |
|
Returns a copy of the allocator object used to construct a list. |
|
Inserts an element or a number of elements or a range of elements into a list at a specified position. |
|
Returns the maximum length of a list. |
|
Removes the elements from the argument list, inserts them into the target list, and orders the new, combined set of elements in ascending order or in some other specified order. |
|
Deletes the element at the end of a list. |
|
Deletes the element at the beginning of a list. |
|
Adds an element to the end of a list. |
|
Adds an element to the beginning of a list. |
|
Returns an iterator addressing the first element in a reversed list. |
|
Erases elements in a list that match a specified value. |
|
Erases elements from the list for which a specified predicate is satisfied. |
|
Returns an iterator that addresses the location succeeding the last element in a reversed list. |
|
Specifies a new size for a list. |
|
Reverses the order in which the elements occur in a list. |
|
Returns the number of elements in a list. |
|
Arranges the elements of a list in ascending order or with respect to some other order relation. |
|
Removes elements from the argument list and inserts them into the target list. |
|
Exchanges the elements of two lists. |
|
Removes adjacent duplicate elements or adjacent elements that satisfy some other binary predicate from the list. |
Operators
Replaces the elements of the list with a copy of another list. |
Requirements
Header: <list>