mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add the ability to hash the contents of a AK::HashMap
This commit is contained in:
parent
df04283d61
commit
54fe0c8855
Notes:
sideshowbarker
2024-07-18 04:08:14 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/54fe0c88551 Pull-request: https://github.com/SerenityOS/serenity/pull/9991 Reviewed-by: https://github.com/awesomekling
1 changed files with 10 additions and 0 deletions
10
AK/HashMap.h
10
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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue