github.com/platonnetwork/platon-go@v0.7.6/cases/tool/win/bls_win/include/cybozu/hash.hpp (about) 1 #pragma once 2 #include <cybozu/inttype.hpp> 3 4 namespace cybozu { 5 6 template<class Iter> 7 uint32_t hash32(Iter begin, Iter end, uint32_t v = 0) 8 { 9 if (v == 0) v = 2166136261U; 10 while (begin != end) { 11 v ^= *begin++; 12 v *= 16777619; 13 } 14 return v; 15 } 16 template<class Iter> 17 uint64_t hash64(Iter begin, Iter end, uint64_t v = 0) 18 { 19 if (v == 0) v = 14695981039346656037ULL; 20 while (begin != end) { 21 v ^= *begin++; 22 v *= 1099511628211ULL; 23 } 24 v ^= v >> 32; 25 return v; 26 } 27 template<class T> 28 uint32_t hash32(const T *x, size_t n, uint32_t v = 0) 29 { 30 return hash32(x, x + n, v); 31 } 32 template<class T> 33 uint64_t hash64(const T *x, size_t n, uint64_t v = 0) 34 { 35 return hash64(x, x + n, v); 36 } 37 38 } // cybozu 39 40 namespace boost { 41 42 template<class T> 43 struct hash; 44 45 } // boost 46 47 #if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 48 #include <functional> 49 #else 50 51 namespace std { CYBOZU_NAMESPACE_TR1_BEGIN 52 53 #ifdef _MSC_VER 54 #pragma warning(push) 55 #pragma warning(disable : 4099) // missmatch class and struct 56 #endif 57 #if !(defined(__APPLE__) && defined(__clang__)) 58 template<class T> 59 struct hash; 60 #endif 61 #ifdef _MSC_VER 62 #pragma warning(pop) 63 #endif 64 65 CYBOZU_NAMESPACE_TR1_END } // std 66 67 #endif