summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-02-22 21:28:36 +0000
committerLinus Groh <mail@linusgroh.de>2022-02-23 21:53:30 +0000
commitf8ff8c8dd69d54c4468e4efd9573261248204cd2 (patch)
tree575754763158a69b84d846f26ccd389988271e35
parent3217b34f5cbb580498268f64675359287c2e9ddf (diff)
downloadserenity-f8ff8c8dd69d54c4468e4efd9573261248204cd2.zip
AK: Add Traits<Span<T>>::hash()
-rw-r--r--AK/Span.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/AK/Span.h b/AK/Span.h
index 93e48bf911..78bcc4c753 100644
--- a/AK/Span.h
+++ b/AK/Span.h
@@ -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>;