Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/uuid/detail/hash_mix.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef BOOST_UUID_DETAIL_HASH_MIX_INCLUDED
0002 #define BOOST_UUID_DETAIL_HASH_MIX_INCLUDED
0003 
0004 // Copyright 2024 Peter Dimov
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // https://www.boost.org/LICENSE_1_0.txt
0007 
0008 #include <cstdint>
0009 
0010 namespace boost {
0011 namespace uuids {
0012 namespace detail {
0013 
0014 // The multipliers are 32 bit, which makes the product
0015 // easier to compute on 32 bit platforms.
0016 //
0017 // The mixing functions have been created with
0018 // https://github.com/skeeto/hash-prospector
0019 
0020 // prospector -p mul,xorr -t 1000
0021 // score = 592.20293470138972
0022 inline std::uint64_t hash_mix_mx( std::uint64_t x ) noexcept
0023 {
0024     x *= 0xD96AAA55;
0025     x ^= x >> 16;
0026     return x;
0027 }
0028 
0029 // prospector -p mul:0xD96AAA55,xorr:16,mul,xorr -t 1000
0030 // score = 79.5223047689704
0031 // (with mx prepended)
0032 inline std::uint64_t hash_mix_fmx( std::uint64_t x ) noexcept
0033 {
0034     x *= 0x7DF954AB;
0035     x ^= x >> 16;
0036     return x;
0037 }
0038 
0039 } // detail
0040 } // uuids
0041 } // boost
0042 
0043 #endif // #ifndef BOOST_UUID_DETAIL_HASH_MIX_INCLUDED