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