Containers library
The Containers library is a generic collection of class templates and algorithms that allow programmers to easily implement common data structures like queues, lists and stacks. There are three classes of containers -- sequence containers, associative containers, and unordered associative containers -- each of which is designed to support a different set of operations.
The container manages the storage space that is allocated for its elements and provides member functions to access them, either directly or through iterators (objects with properties similar to pointers).
Most containers have at least several member functions in common, and share functionalities. Which container is the best for the particular application depends not only on the offered functionality, but also on its efficiency for different workloads.
Contents |
Sequence containers
Sequence containers implement data structures which can be accessed sequentially.
(C++11) |
fixed-sized inplace contiguous array (class template) |
dynamic contiguous array (class template) | |
double-ended queue (class template) | |
(C++11) |
singly-linked list (class template) |
doubly-linked list (class template) |
Associative containers
Associative containers implement sorted data structures that can be quickly searched (O(log n) complexity).
collection of unique keys, sorted by keys (class template) | |
collection of key-value pairs, sorted by keys, keys are unique (class template) | |
collection of keys, sorted by keys (class template) | |
collection of key-value pairs, sorted by keys (class template) |
Unordered associative containers
Unordered associative containers implement unsorted (hashed) data structures that can be quickly searched (O(1) amortized, O(n) worst-case complexity).
(C++11) |
collection of unique keys, hashed by keys (class template) |
(C++11) |
collection of key-value pairs, hashed by keys, keys are unique (class template) |
(C++11) |
collection of keys, hashed by keys (class template) |
(C++11) |
collection of key-value pairs, hashed by keys (class template) |
Container adaptors
Container adaptors provide a different interface for sequential containers.
adapts a container to provide stack (LIFO data structure) (class template) | |
adapts a container to provide queue (FIFO data structure) (class template) | |
adapts a container to provide priority queue (class template) |
Iterator invalidation
This section is incomplete |
Thread safety
|
(since C++11) |
Member function table
- functions present in C++03 | |
- functions present since C++11 | |
- functions present since C++17 |
(A PDF version of this table is available at File:container-library-overview-2012-12-27.pdf.)