mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
AK: Add Traits<Span<T>>::hash()
This commit is contained in:
parent
3217b34f5c
commit
f8ff8c8dd6
1 changed files with 13 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue