summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-09-11 20:17:40 -0700
committerAndreas Kling <kling@serenityos.org>2021-09-12 16:39:23 +0200
commit54fe0c88551ef5ca42ec18dadaf7b46d530f8535 (patch)
treea5bcdd740420eb5ccbde086f6350666855d8907b
parentdf04283d6156182012cd13f8c6c8e60a0605da7e (diff)
downloadserenity-54fe0c88551ef5ca42ec18dadaf7b46d530f8535.zip
AK: Add the ability to hash the contents of a AK::HashMap
-rw-r--r--AK/HashMap.h10
1 files changed, 10 insertions, 0 deletions
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;
};