what is a container :
is a data structure that allows us to store data in a organized way that allow manipulation of the data depending on the type of container
Where and when to use a container ?
1️⃣ Access pattern matters
- Random access (access elements by index quickly) → use
vector or deque.
- Sequential access (traverse elements in order) →
list or forward_list work well.
- Key-based access (look up values by key) →
map or unordered_map.
2️⃣ Modification pattern matters
- Frequent insertion/removal at ends →
deque or list.
- Frequent insertion/removal in the middle →
list or forward_list.
- Need to maintain sorted order automatically →
set or map.
3️⃣ Special operations
- Stack behavior (LIFO) → use
stack.
- Queue behavior (FIFO) → use
queue.
- Priority-based processing → use
priority_queue.
4️⃣ Example decisions