Explorar o código

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

Linus Groh %!s(int64=3) %!d(string=hai) anos
pai
achega
f8ff8c8dd6
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      AK/Span.h

+ 13 - 0
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>;