Hash Maps

C++
Author

Quasar

Published

December 25, 2025

Introduction

std::unordered_map is C++’s hash table container, providing \(O(1)\) constant-time insertion, loopkup and delete operations on average. In this blog post, I explore the basic API of unordered_map.

Construction

std::unordered_map is a class template in the header <unordered_map>.

namespace pmr {

    template<
        class Key,
        class T,
        class Hash = std::hash<Key>,
        class KeyEqual = std::equal_to<Key>
    > using unordered_map =
          std::unordered_map<Key, T, Hash, KeyEqual,
              std::pmr::polymorphic_allocator<std::pair<const Key, T>>>;
}