C++ Container Usage

Generalize

Picture 2013-05-10 17_41_33 

Sequence containers 序列容器

Array, c++11

std::forward_list, c++11

singly-linked lists

main design difference between a forward_list container and a list container is that the first keeps internally only a link to the next element, while the latter keeps two links per element: one pointing to the next element and one to the preceding one, allowing efficient iteration in both directions, but consuming additional storage per element and with a slight higher time overhead inserting and removing elements. forward_list objects are thus more efficient than list objects, although they can only be iterated forwards.

Compared to other base standard sequence containers (array, vector and deque), forward_list perform generally better in inserting, extracting and moving elements in any position within the container, and therefore also in algorithms that make intensive use of these, like sorting algorithms.

原文地址:https://www.cnblogs.com/rogerroddick/p/3071616.html