- support for custom memory allocators
- for loops
begin()/cbegin()&end()/cend()- (constant) iteratorssize(),empty(),reserve()[]- doesn't check out of range.at()- throwsstd::out_of_range, small performance overheadpush_back(pair{1, "a"})emplace_back({1, "a"}))- wraps into value typec=c2- copy allc==c2- equality of all elements
- store pointers to get polymorphic behavior
- elements are copied into containers
- pass container by reference
- unordered means faster lookup
- resize corrupts iterators and pointers
- OO version of built-in array
include <array> std::array<int, 5> arr = {1, 2, 3, 4, 5};
- default choice for sequences
- dynamic array (~
ArrayList)
- doubly linked list
- singly linked list
- good for empty, 1-2 elements sequences because occupies only 1 word of memory
[]- creates a new element (default value) if it doesn't existfind- returns an iterator to the element if it exists, otherwise returnsend()iterator- ordered map (red-black tree)
O(log n)for insert, find, delete
- variants
unordered_- hash tablemulti- multiple keys
bitsettuplepairvector<bool>- store bools as bitsvalarray