template < class T, class Alloc = allocator<T> > class list;
Lists are sequence containers that allow constant time insert and erase operations anywhere within the sequence, and iteration in both directions.
list是一种序列容器,它允许在常数时间内向序列中的任何位置插入或删除元素,以及双向迭代。

List containers are implemented as doubly-linked lists; Doubly linked lists can store each of the elements they contain in different and unrelated storage locations. The ordering is kept internally by the association to each element of a link to the element preceding it and a link to the element following it.
list容器作为双向链表实现,双向链表可以将其元素存储在不同的、不相关的位置。在内部,顺序是通过元素之间的关联实现的。

They are very similar to forward_list: The main difference being that forward_list objects are single-linked lists, and thus they can only be iterated forwards, in exchange for being somewhat smaller and more efficient.
他们与forward_list很相似,主要区别在于forward_list对象是单链表,因此只能向前迭代,以换取更小、更高效。

Compared to other base standard sequence containers (array, vector and deque), lists perform generally better in inserting, extracting and moving elements in any position within the container for which an iterator has already been obtained, and therefore also in algorithms that make intensive use of these, like sorting algorithms.
和其他基础标准序列容器(array、vector、deque)相比,list在任何位置插入、提取和移动元素表现的都好,因为迭代器已经获得,因此在大量使用这些元素的算法(如排序算法)中通常表现的更好。

The main drawback of lists and forward_lists compared to these other sequence containers is that they lack direct access to the elements by their position; For example, to access the sixth element in a list, one has to iterate from a known position (like the beginning or the end) to that position, which takes linear time in the distance between these. They also consume some extra memory to keep the linking information associated to each element (which may be an important factor for large lists of small-sized elements).
与其他序列容器相比,list和forward_list的主要缺点是无法通过元素位置直接访问元素。而且由于要保存元素之间的关联信息,因此占用空间较大。

插入元素

single element (1) iterator insert (const_iterator position, const value_type& val);
fill (2) iterator insert (const_iterator position, size_type n, const value_type& val);
range (3) template iterator insert (const_iterator position, InputIterator first, InputIterator last);
move (4) iterator insert (const_iterator position, value_type&& val);
initializer list (5) iterator insert (const_iterator position, initializer_list il);
  1. void push_front (const value_type& val);
  2. void push_front (value_type&& val);
  3. void push_back (const value_type& val);
  4. void push_back (value_type&& val);