123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef BOOST_INTRUSIVE_DETAIL_HASH_MIX_HPP
- #define BOOST_INTRUSIVE_DETAIL_HASH_MIX_HPP
- #include <boost/cstdint.hpp> //boost::uint64_t
- #include <cstddef>
- #include <climits>
- namespace boost {
- namespace intrusive {
- namespace detail {
-
- template<std::size_t Bits> struct hash_mix_impl;
- template<> struct hash_mix_impl<64>
- {
- inline static boost::uint64_t fn( boost::uint64_t x )
- {
- boost::uint64_t const m = 0xe9846af9b1a615d;
- x ^= x >> 32;
- x *= m;
- x ^= x >> 32;
- x *= m;
- x ^= x >> 28;
- return x;
- }
- };
- template<> struct hash_mix_impl<32>
- {
- inline static boost::uint32_t fn( boost::uint32_t x )
- {
- boost::uint32_t const m1 = 0x21f0aaad;
- boost::uint32_t const m2 = 0x735a2d97;
- x ^= x >> 16;
- x *= m1;
- x ^= x >> 15;
- x *= m2;
- x ^= x >> 15;
- return x;
- }
- };
- inline std::size_t hash_mix( std::size_t v )
- {
- return hash_mix_impl<sizeof(std::size_t) * CHAR_BIT>::fn( v );
- }
- }
- }
- }
- #endif
|