Add tsl::robin_map to uint64.cpp, string_view.cpp

This commit is contained in:
Peter Dimov
2022-07-22 18:52:47 +03:00
parent 0ca8c5f56f
commit 4e804a9d4d
2 changed files with 73 additions and 2 deletions

View File

@@ -17,6 +17,9 @@
#ifdef HAVE_TSL_HOPSCOTCH #ifdef HAVE_TSL_HOPSCOTCH
# include "tsl/hopscotch_map.h" # include "tsl/hopscotch_map.h"
#endif #endif
#ifdef HAVE_TSL_ROBIN
# include "tsl/robin_map.h"
#endif
#include <unordered_map> #include <unordered_map>
#include <string_view> #include <string_view>
#include <vector> #include <vector>
@@ -141,7 +144,14 @@ template<class Map> BOOST_NOINLINE void test_iteration( Map& map, std::chrono::s
{ {
if( it->second & 1 ) if( it->second & 1 )
{ {
map.erase( it++ ); if constexpr( std::is_void_v< decltype( map.erase( it ) ) > )
{
map.erase( it++ );
}
else
{
it = map.erase( it );
}
} }
else else
{ {
@@ -309,6 +319,16 @@ template<class K, class V> using tsl_hopscotch_pg_map =
#endif #endif
#ifdef HAVE_TSL_ROBIN
template<class K, class V> using tsl_robin_map =
tsl::robin_map<K, V, std::hash<K>, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
template<class K, class V> using tsl_robin_pg_map =
tsl::robin_pg_map<K, V, std::hash<K>, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
#endif
// fnv1a_hash // fnv1a_hash
template<int Bits> struct fnv1a_hash_impl; template<int Bits> struct fnv1a_hash_impl;
@@ -387,6 +407,16 @@ template<class K, class V> using tsl_hopscotch_pg_map_fnv1a =
#endif #endif
#ifdef HAVE_TSL_ROBIN
template<class K, class V> using tsl_robin_map_fnv1a =
tsl::robin_map<K, V, fnv1a_hash, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
template<class K, class V> using tsl_robin_pg_map_fnv1a =
tsl::robin_pg_map<K, V, fnv1a_hash, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
#endif
// //
int main() int main()
@@ -413,6 +443,13 @@ int main()
#endif #endif
#ifdef HAVE_TSL_ROBIN
test<tsl_robin_map>( "tsl::robin_map" );
test<tsl_robin_pg_map>( "tsl::robin_pg_map" );
#endif
#endif #endif
test<std_unordered_map_fnv1a>( "std::unordered_map, FNV-1a" ); test<std_unordered_map_fnv1a>( "std::unordered_map, FNV-1a" );
@@ -431,6 +468,13 @@ int main()
test<tsl_hopscotch_map_fnv1a>( "tsl::hopscotch_map, FNV-1a" ); test<tsl_hopscotch_map_fnv1a>( "tsl::hopscotch_map, FNV-1a" );
test<tsl_hopscotch_pg_map_fnv1a>( "tsl::hopscotch_pg_map, FNV-1a" ); test<tsl_hopscotch_pg_map_fnv1a>( "tsl::hopscotch_pg_map, FNV-1a" );
#endif
#ifdef HAVE_TSL_ROBIN
test<tsl_robin_map_fnv1a>( "tsl::robin_map, FNV-1a" );
test<tsl_robin_pg_map_fnv1a>( "tsl::robin_pg_map, FNV-1a" );
#endif #endif
std::cout << "---\n\n"; std::cout << "---\n\n";

View File

@@ -18,6 +18,9 @@
#ifdef HAVE_TSL_HOPSCOTCH #ifdef HAVE_TSL_HOPSCOTCH
# include "tsl/hopscotch_map.h" # include "tsl/hopscotch_map.h"
#endif #endif
#ifdef HAVE_TSL_ROBIN
# include "tsl/robin_map.h"
#endif
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <memory> #include <memory>
@@ -150,7 +153,14 @@ template<class Map> BOOST_NOINLINE void test_iteration( Map& map, std::chrono::s
{ {
if( it->second & 1 ) if( it->second & 1 )
{ {
map.erase( it++ ); if constexpr( std::is_void_v< decltype( map.erase( it ) ) > )
{
map.erase( it++ );
}
else
{
it = map.erase( it );
}
} }
else else
{ {
@@ -325,6 +335,16 @@ template<class K, class V> using tsl_hopscotch_pg_map =
#endif #endif
#ifdef HAVE_TSL_ROBIN
template<class K, class V> using tsl_robin_map =
tsl::robin_map<K, V, std::hash<K>, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
template<class K, class V> using tsl_robin_pg_map =
tsl::robin_pg_map<K, V, std::hash<K>, std::equal_to<K>, ::allocator< std::pair<K, V> >>;
#endif
int main() int main()
{ {
init_indices(); init_indices();
@@ -345,6 +365,13 @@ int main()
test<tsl_hopscotch_map>( "tsl::hopscotch_map" ); test<tsl_hopscotch_map>( "tsl::hopscotch_map" );
test<tsl_hopscotch_pg_map>( "tsl::hopscotch_pg_map" ); test<tsl_hopscotch_pg_map>( "tsl::hopscotch_pg_map" );
#endif
#ifdef HAVE_TSL_ROBIN
test<tsl_robin_map>( "tsl::robin_map" );
test<tsl_robin_pg_map>( "tsl::robin_pg_map" );
#endif #endif
std::cout << "---\n\n"; std::cout << "---\n\n";