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.
For a list of all members of this type, see list Class Members.
The choice of container type should be based generally 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 start and the end of a sequence are at a premium.
List reallocation occurs when a member function must insert or delete elements of the list. In all such cases, only iterators or references that point at erased parts of the controlled sequence become invalid.
Include the STL standard header <list> to define the container template class list and several supporting templates.