Tsallaka zuwa abun ciki
Justice Tech School

array, deque and list

std::array is a fixed size array with a size, deque is a double ended queue and list is a doubly linked list. Pick the container by how you use it.

Example
#include <array>
#include <deque>
#include <list>
array<int, 3> a = {1, 2, 3};
deque<int> d = {2, 3};
d.push_front(1);
list<int> l = {3, 1, 2};
l.sort();
cout << a.size() << " " << d.front() << " ";
for (int x : l) cout << x;
cout << "\n";

Result

3 1 123

Exercise

Fixed size container.

std::<int, 3> a

Quiz Test

Which allows push_front cheaply?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.