diff options
Diffstat (limited to 'lib/include/array_hash.hpp')
-rw-r--r-- | lib/include/array_hash.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/include/array_hash.hpp b/lib/include/array_hash.hpp new file mode 100644 index 0000000..3b35e4a --- /dev/null +++ b/lib/include/array_hash.hpp @@ -0,0 +1,27 @@ + +#pragma once + +#include <array> +#include <unordered_map> + +namespace std +{ + template<typename T, size_t N> + struct hash<array<T, N> > + { + typedef array<T, N> argument_type; + typedef size_t result_type; + + result_type operator()(const argument_type& a) const + { + hash<T> hasher; + result_type h = 0; + for (result_type i = 0; i < N; ++i) + { + h = h * 31 + hasher(a[i]); + } + return h; + } + }; +} + |