From 54fe0c88551ef5ca42ec18dadaf7b46d530f8535 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 11 Sep 2021 20:17:40 -0700 Subject: [PATCH] AK: Add the ability to hash the contents of a AK::HashMap --- AK/HashMap.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AK/HashMap.h b/AK/HashMap.h index f707c66068..4d4cdc516a 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -165,6 +165,16 @@ public: return list; } + [[nodiscard]] u32 hash() const + { + u32 hash = 0; + for (auto& it : *this) { + auto entry_hash = pair_int_hash(it.key.hash(), it.value.hash()); + hash = pair_int_hash(hash, entry_hash); + } + return hash; + } + private: HashTableType m_table; };