#include #include // for __gnu_cxx::hash #include "MurmurHash2.h" #include "stringpiece.h" #include "cmph_types.h" namespace cxxmph { template struct seeded_hash_function { template cmph_uint32 operator()(const Key& k, cmph_uint32 seed) const { return HashFcn()(k) ^ seed; } }; struct Murmur2 { template cmph_uint32 operator()(const Key& k) const { return MurmurHash2(k, sizeof(Key), 1 /* seed */); } }; struct Murmur2StringPiece { template cmph_uint32 operator()(const Key& k) const { StringPiece s(k); return MurmurHash2(k.data(), k.length(), 1 /* seed */); } }; template <> struct seeded_hash_function { template cmph_uint32 operator()(const Key& k, cmph_uint32 seed) const { return MurmurHash2(k, sizeof(Key), seed); } }; template <> struct seeded_hash_function { template cmph_uint32 operator()(const Key& k, cmph_uint32 seed) const { StringPiece s(k); return MurmurHash2(k.data(), k.length(), seed); } }; template struct OptimizedSeededHashFunction { typedef seeded_hash_function hash_function; }; // Use Murmur2 instead for all types defined in __gnu_cxx::hash, plus // std::string which is commonly extended. template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; template <> struct OptimizedSeededHashFunction<__gnu_cxx::hash > { typedef seeded_hash_function hash_function; }; } // namespace cxxmph