In C++ STL, sequence containers are data structures that store elements in a linear order, allowing sequential access. The main sequence containers are: array, vector, deque, list, and forward_list.
iteration: the process of repeating a mathematical or computing process or set of instructions again and again, each time applying it to the result of the previous stage
dribble (something) (+ adv./prep.) (in football (soccer) and some other sports) to move the ball along with several short kicks, hits or bounces
for (const auto& action : recentActions)
The above line is a range-based for loop in C++.
for → Starts the loop.
const auto& action →
auto deduces the type of each element in recentActions.
& means we’re iterating by reference (no copy is made).
const ensures the element cannot be modified inside the loop.
: recentActions → The container we’re iterating over (e.g., std::vector, std::list, etc.).
deduce: to form an opinion about something based on the information or evidence that is available
recentActions is the container (e.g., std::vector, std::list, etc.) that holds multiple elements.
action is a reference to each individual element inside recentActions as the loop iterates.
In C++, std::list is a sequence container implemented as a doubly linked list. It allows fast insertions and deletions anywhere in the sequence but does not support random access like arrays or vectors.
In C++, associative containers are part of the Standard Template Library (STL) that store elements in a way that allows fast retrieval based on keys rather than positions. The main ordered associative containers are: set, multiset, map, and multimap.
Defined in the <set> header as std::set<T>.
Stores unique elements in a sorted order.
Internally implemented as a balanced binary search tree (usually a Red-Black Tree).
Provides logarithmic time complexity (O(log n)) for insertion, deletion, and search.
A side-scrolling video game (alternatively side-scroller) is a video game viewed from a side-view camera angle where the screen follows the player as they move left or right.
The dot (.) operator in C++ is one of the fundamental operators used for member access.
The dot operator (.) is used to access members (variables, functions, or nested types) of an object, struct, or class directly.
It works when you have an object (not a pointer).
The std::pair class in C++ is a simple but powerful utility that lets you store two values together as a single unit. It’s defined in the <utility> header.
std::pair<std::string, int> playerStats("Alice", 75);
The above line of code is creating a std::pair object named playerStats with two values:
first → "Alice" (a std::string)
second → 75 (an int)
Defined in the <map> header as std::map<Key,T>.
Stores key–value pairs where:
Key → unique identifier.
Value (T) → data associated with the key.
Internally implemented as a balanced binary search tree (usually a Red-Black Tree).
Keys are always kept in sorted order (by default using std::less<Key>).
In C++, unordered containers are part of the STL that store elements in hash tables rather than sorted trees. They provide average constant-time (O(1)) performance for insertion, deletion, and lookup, but do not maintain any order of elements.
Container adapters are special containers that provide a restricted interface built on top of other sequence containers (like deque, list, or vector).
They don’t store elements in a unique way themselves; instead, they adapt existing containers to provide specific behaviors.
Defined in the <queue> and <stack> headers.
Last in First out
It’s a data access principle used in computer science and programming.
Think of it like a stack of plates: the last plate you put on top is the first one you take off.
In C++, this principle is implemented using the std::stack container adapter.
empty()
Checks whether the stack has any elements.
top()
Returns a reference to the top element of the stack (the last pushed element).
Does not remove the element.
pop()
Removes the top element from the stack.
FIFO is the opposite of LIFO (Last In, First Out).
Think of it like a line at a store: the first person to enter the line is the first person served.
In C++, FIFO is implemented using the std::queue container adapter.
front() gives you a reference to the first element in the container.
Does not remove the element (unlike pop() in a queue).
Undefined behavior if called on an empty container (so always check with empty() first).
Defined in the <queue> header as std::priority_queue.
Stores elements in a way that the highest priority element is always accessible at the top.
Internally implemented using a heap structure (by default, a max-heap built on top of a std::vector).
std::priority_queue<int> aiTasks;
std::priority_queue → A priority queue of integers.
aiTasks → The variable name.
By default, std::priority_queue is a max-heap, meaning the largest integer will always be at the top.
In C++ STL, container adapters are special wrappers that provide a specialized interface on top of existing sequence containers (like deque, list, or vector). Instead of exposing all the operations of the underlying container, they restrict and tailor the interface to enforce a particular usage pattern.
Microsoft Copilot