AK: Add Traits<Span<T>>::hash()

This commit is contained in:
Linus Groh 2022-02-22 21:28:36 +00:00
parent 3217b34f5c
commit f8ff8c8dd6

View file

@ -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>;