4. Sequential Containers
The sequential container have a lot in common, but each container has its special domain. Before I dive into the details, I provide the overview of all five sequential containers of the std namespace.
Criteria | array | vector | deque | list | forward_list |
---|---|---|---|---|---|
Size | static | dynamic | dynamic | dynamic | dynamic |
Implementation | static array | dynamic array | sequence of arrays | doubled linked list | single linked list |
Access | random | random | random | forward and backward | forward |
Optimized for insert and delete at | end: O(1) | begin and end: O(1) | begin and end: O(1) | begin(1) | |
arbitrary: O(1) | arbitrary: O(1) | ||||
Memory reservation... |