This quick reference cheat sheet provides a rapid lookup guide to modern C++ syntax, keywords, standard library containers, and mathematical time complexities.
| Container | Data Structure | Random Access [] |
Front Insert/Delete | Back Insert/Delete | Search Complexity |
|---|---|---|---|---|---|
std::vector |
Contiguous Array | $O(1)$ | $O(N)$ | $O(1)$ Amortized | $O(N)$ linear / $O(log N)$ sorted |
std::deque |
Chunked Buffers | $O(1)$ | $O(1)$ | $O(1)$ | $O(N)$ |
std::list |
Doubly Linked List | $O(N)$ (No []) |
$O(1)$ | $O(1)$ | $O(N)$ |
std::set / map |
Red-Black Tree | $O(log N)$ (map only) | $O(log N)$ | $O(log N)$ | $O(log N)$ Guaranteed |
std::unordered_map |
Hash Table | $O(1)$ Average | $O(1)$ Average | $O(1)$ Average | $O(1)$ Average ($O(N)$ worst) |
std::stack |
Adapter (Deque) | Not supported | Not supported | $O(1)$ Push/Pop | $O(1)$ Top only |
std::priority_queue |
Binary Max/Min Heap | Not supported | Not supported | $O(log N)$ Push/Pop | $O(1)$ Top element |
// Smart Pointers
auto uPtr = std::make_unique<MyClass>(arg); // Unique ownership (no copy)
auto sPtr = std::make_shared<MyClass>(arg); // Shared ownership (ref count)
// Range-based for loop
for (const auto& item : container) { ... } // Zero copy read-only
// Structured Bindings (C++17)
auto [key, value] = *mapIterator;
// Lambdas
auto isPositive = [](int x) { return x > 0; };
// Concepts (C++20)
template <std::integral T>
T gcd(T a, T b);
Boost your C++ proficiency by studying these closely connected core modules:
Return to the comprehensive tutorial homepage.
Practical implementation exercises.
Top placement questions and answers.