AlgoMaster Logo

std::unordered_map & std::unordered_multimap

Last Updated: May 17, 2026

8 min read

std::unordered_map<Key, Value> is a hash-table-backed key-value container that gives average O(1) insert, find, and erase. It's the hash counterpart to std::map, and like std::unordered_set from the previous chapter, it trades sorted order for raw speed. std::unordered_multimap is the duplicate-keys variant. This chapter covers the storage layout, the API including the operator[] insertion gotcha, custom hashing for user-defined keys, rehashing behaviour, and when to reach for unordered_map over map.

Premium Content

Subscribe to unlock full access to this content and more premium articles.