The Containers library is a generic collection of class templates and algorithms that allow programmers to easily implement comment data structures like queues, lists and stacks. There are three classes of containers: sequence containers, associative containers and unordered associativecontainers, each of which is designed to support a different set of operations.

Which container is the best for the particular application depends not only on the offered functionality, but also on its efficiency for different workloads.

结构与分类

Sequence containers and Associative containers

image.png

Container adaptors

Container adaptors provide a different interface for sequential containers. | stack | adapts a container to provide stack (LIFO data structure)
(class template) | | —- | —- | | queue | adapts a container to provide queue (FIFO data structure)
(class template) | | priority_queue | adapts a container to provide priority queue
(class template) |

Sequence containers

Sequence containers implement data structures which can be accessed sequentially.

array

std::array is a container that encapsulates fixed size arrays.
Note: As a rule, iterators to an array are never invalidated throughout the lifetime of the array.

vector

Reference

  1. C++ Container Library