diff options
author | Linus Groh <mail@linusgroh.de> | 2022-02-22 21:28:36 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-23 21:53:30 +0000 |
commit | f8ff8c8dd69d54c4468e4efd9573261248204cd2 (patch) | |
tree | 575754763158a69b84d846f26ccd389988271e35 | |
parent | 3217b34f5cbb580498268f64675359287c2e9ddf (diff) | |
download | serenity-f8ff8c8dd69d54c4468e4efd9573261248204cd2.zip |
AK: Add Traits<Span<T>>::hash()
-rw-r--r-- | AK/Span.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -220,6 +220,19 @@ public: } }; +template<typename T> +struct Traits<Span<T>> : public GenericTraits<Span<T>> { + static unsigned hash(Span<T> const& span) + { + unsigned hash = 0; + for (auto const& value : span) { + auto value_hash = Traits<T>::hash(value); + hash = pair_int_hash(hash, value_hash); + } + return hash; + } +}; + using ReadonlyBytes = Span<u8 const>; using Bytes = Span<u8>; |