From f8ff8c8dd69d54c4468e4efd9573261248204cd2 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 22 Feb 2022 21:28:36 +0000 Subject: [PATCH] AK: Add Traits>::hash() --- AK/Span.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 +struct Traits> : public GenericTraits> { + static unsigned hash(Span const& span) + { + unsigned hash = 0; + for (auto const& value : span) { + auto value_hash = Traits::hash(value); + hash = pair_int_hash(hash, value_hash); + } + return hash; + } +}; + using ReadonlyBytes = Span; using Bytes = Span;