Short note about C++ containers — Arrays, Vectors, Lists and Maps

Ansif Ibrahimkutty
2 min readOct 19, 2023


Arrays have a fixed size, defined at the time of declaration.
They offer direct memory access to elements.
Cannot be resized without creating a new array.


Vectors are dynamic arrays that can grow or shrink in size.
They provide direct memory access and are more efficient than lists for random access.
Automatic memory management and use contiguous memory for efficient cache usage

Lists (std::list)

Linked lists consist of nodes, allowing for efficient insertions and deletions anywhere in the list.
Not suitable for random access due to the lack of direct memory access.
Consumes more memory than vectors due to node overhead.

Maps (std::map)

Maps are associative containers that store key-value pairs.
Elements are stored in a sorted order based on keys.
Lookup, insertion, and deletion of elements are efficient for ordered data.

There are around 21 containers in C++. Here i have seperated out all of them and added the complete list of C++ containers below

Sequence Containers:
1. Array (std::array)
2. Vector (std::vector)
3. Deque (std::deque)
4. List (std::list)
5. Forward List (std::forward_list)

Associative Containers:
6. Set (std::set)
7. Multiset (std::multiset)
8. Map (std::map)
9. Multimap (std::multimap)

Unordered Containers:
10. Unordered Set (std::unordered_set)
11. Unordered Multiset (std::unordered_multiset)
12. Unordered Map (std::unordered_map)
13. Unordered Multimap (std::unordered_multimap)

Container Adapters:
14. Stack (std::stack)
15. Queue (std::queue)
16. Priority Queue (std::priority_queue)

Associative Arrays (C++11 and later):
17. Array-based Map (std::array, std::map)
18. Unordered Associative Containers (std::unordered_set, std::unordered_multiset, std::unordered_map, std::unordered_multimap)

Additional Containers (C++17 and later):
19. String View (std::string_view)
20. String (std::string)
21. Bitset (std::bitset)

These containers serve various purposes and have different characteristics, making them suitable for a wide range of data storage and manipulation tasks in C++. Your choice of container depends on the specific requirements of your program, such as the type of data you need to store, the operations you need to perform, and the efficiency and memory considerations.