Study
C++ · STL: map and unordered_map
Ordered std::map (a balanced tree) versus std::unordered_map (a hash table), lookups with find/count, and the operator[] side effect.
- std::map keeps keys sorted (O(log n)); std::unordered_map is a hash table (O(1) average) with no ordering.
- m[key] inserts a default value if the key is missing, so use find() just to check.