mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Add xmx2_mix
This commit is contained in:
@ -292,6 +292,9 @@ template<class K, class V> using boost_unordered_map =
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx2 =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx2_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_mulx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::mulx_mix>;
|
||||
|
||||
@ -319,6 +322,7 @@ int main()
|
||||
test<std_unordered_map>( "std::unordered_map" );
|
||||
test<boost_unordered_map>( "boost::unordered_map" );
|
||||
test<boost_unordered_flat_map_xmx>( "boost::unordered_flat_map, xmx" );
|
||||
test<boost_unordered_flat_map_xmx2>( "boost::unordered_flat_map, xmx2" );
|
||||
test<boost_unordered_flat_map_mulx>( "boost::unordered_flat_map, mulx" );
|
||||
|
||||
#ifdef HAVE_ANKERL_UNORDERED_DENSE
|
||||
@ -338,7 +342,7 @@ int main()
|
||||
|
||||
for( auto const& x: times )
|
||||
{
|
||||
std::cout << std::setw( 33 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
std::cout << std::setw( 34 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,6 +292,9 @@ template<class K, class V> using boost_unordered_map =
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx2 =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx2_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_mulx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::mulx_mix>;
|
||||
|
||||
@ -329,6 +332,7 @@ int main()
|
||||
|
||||
test<boost_unordered_map>( "boost::unordered_map" );
|
||||
test<boost_unordered_flat_map_xmx>( "boost::unordered_flat_map, xmx" );
|
||||
test<boost_unordered_flat_map_xmx2>( "boost::unordered_flat_map, xmx2" );
|
||||
test<boost_unordered_flat_map_mulx>( "boost::unordered_flat_map, mulx" );
|
||||
|
||||
#ifdef HAVE_ANKERL_UNORDERED_DENSE
|
||||
@ -348,7 +352,7 @@ int main()
|
||||
|
||||
for( auto const& x: times )
|
||||
{
|
||||
std::cout << std::setw( 33 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
std::cout << std::setw( 34 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,9 @@ template<class K, class V> using boost_unordered_map =
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx2 =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx2_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_mulx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::mulx_mix>;
|
||||
|
||||
@ -370,6 +373,7 @@ int main()
|
||||
test<std_unordered_map>( "std::unordered_map" );
|
||||
test<boost_unordered_map>( "boost::unordered_map" );
|
||||
test<boost_unordered_flat_map_xmx>( "boost::unordered_flat_map, xmx" );
|
||||
test<boost_unordered_flat_map_xmx2>( "boost::unordered_flat_map, xmx2" );
|
||||
test<boost_unordered_flat_map_mulx>( "boost::unordered_flat_map, mulx" );
|
||||
|
||||
#ifdef HAVE_ANKERL_UNORDERED_DENSE
|
||||
@ -389,7 +393,7 @@ int main()
|
||||
|
||||
for( auto const& x: times )
|
||||
{
|
||||
std::cout << std::setw( 33 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
std::cout << std::setw( 34 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,9 @@ template<class K, class V> using boost_unordered_map =
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_xmx2 =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::xmx2_mix>;
|
||||
|
||||
template<class K, class V> using boost_unordered_flat_map_mulx =
|
||||
boost::unordered_flat_map<K, V, boost::hash<K>, std::equal_to<K>, allocator_for<K, V>, boost::unordered::detail::foa::mulx_mix>;
|
||||
|
||||
@ -211,6 +214,7 @@ int main()
|
||||
test<std_unordered_map>( "std::unordered_map" );
|
||||
test<boost_unordered_map>( "boost::unordered_map" );
|
||||
test<boost_unordered_flat_map_xmx>( "boost::unordered_flat_map, xmx" );
|
||||
test<boost_unordered_flat_map_xmx2>( "boost::unordered_flat_map, xmx2" );
|
||||
test<boost_unordered_flat_map_mulx>( "boost::unordered_flat_map, mulx" );
|
||||
|
||||
#ifdef HAVE_ANKERL_UNORDERED_DENSE
|
||||
@ -230,7 +234,7 @@ int main()
|
||||
|
||||
for( auto const& x: times )
|
||||
{
|
||||
std::cout << std::setw( 33 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
std::cout << std::setw( 34 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,6 +761,15 @@ struct xmx_mix
|
||||
}
|
||||
};
|
||||
|
||||
struct xmx2_mix
|
||||
{
|
||||
template<typename Hash,typename T>
|
||||
static inline std::size_t mix(const Hash& h,const T& x)
|
||||
{
|
||||
return xmx2(h(x));
|
||||
}
|
||||
};
|
||||
|
||||
struct mulx_mix
|
||||
{
|
||||
template<typename Hash,typename T>
|
||||
|
@ -64,6 +64,31 @@ static inline std::size_t xmx(std::size_t x)noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
// alternative multipliers
|
||||
|
||||
static inline std::size_t xmx2( std::size_t x ) noexcept
|
||||
{
|
||||
#if defined(BOOST_UNORDERED_64B_ARCHITECTURE)
|
||||
|
||||
boost::uint64_t z=(boost::uint64_t)x;
|
||||
|
||||
z ^= z >> 23;
|
||||
z *= 0x9E3779B97F4A7C15ull;
|
||||
z ^= z >> 23;
|
||||
|
||||
return (std::size_t)z;
|
||||
|
||||
#else /* 32 bits assumed */
|
||||
|
||||
x ^= x >> 18;
|
||||
x *= 0x9E3779B9u;
|
||||
x ^= x >> 16;
|
||||
|
||||
return x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BOOST_UNORDERED_64B_ARCHITECTURE
|
||||
#undef BOOST_UNORDERED_64B_ARCHITECTURE
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user