mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
AK: Add Traits<Span<T>>::hash()
This commit is contained in:
parent
3217b34f5c
commit
f8ff8c8dd6
13
AK/Span.h
13
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>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue