Tag: vector
5 posts
-
vector vs list vs deque: Why Cache Locality Usually Beats Big-O
Choosing between C++ STL vector, list and deque: internal layouts, time complexity, real benchmarks showing cache effects, and a situation-by-situation selection guide.
-
std::vector in Practice: reserve vs resize, Iterator Invalidation and 2D Vectors
std::vector explained: why it beats raw arrays, reserve vs resize, iterator invalidation, algorithms, 2D vectors, and practical examples with pitfalls.
-
C++ Iterator Invalidation: “vector iterators incompatible”
Iterator invalidation rules for vector, deque, list, map and unordered_map, ten bugs behind 'vector iterators incompatible', and fixes using erase's return.
-
C++ Array vs vector: Performance, Safety, and When to Use
C arrays, std::array, and std::vector compared: where the memory lives, pointer decay, bounds checks, copy semantics, and where the real performance cost is.
-
C++ vector reserve vs resize: When to Use Which
vector::reserve changes capacity only while resize changes size and constructs elements. Covers the v[i]-after-reserve bug, growth rules, and reserve-in-a-loop.