diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-09-11 20:17:40 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-12 16:39:23 +0200 |
commit | 54fe0c88551ef5ca42ec18dadaf7b46d530f8535 (patch) | |
tree | a5bcdd740420eb5ccbde086f6350666855d8907b | |
parent | df04283d6156182012cd13f8c6c8e60a0605da7e (diff) | |
download | serenity-54fe0c88551ef5ca42ec18dadaf7b46d530f8535.zip |
AK: Add the ability to hash the contents of a AK::HashMap
-rw-r--r-- | AK/HashMap.h | 10 |
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; }; |