mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-12 14:01:43 +00:00
Add tsl::hopscotch_map to string.cpp
This commit is contained in:
parent
be467b3dc4
commit
b7101494f2
@ -14,6 +14,9 @@
|
|||||||
# include "absl/container/node_hash_map.h"
|
# include "absl/container/node_hash_map.h"
|
||||||
# include "absl/container/flat_hash_map.h"
|
# include "absl/container/flat_hash_map.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_TSL_HOPSCOTCH
|
||||||
|
# include "tsl/hopscotch_map.h"
|
||||||
|
#endif
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -295,6 +298,16 @@ template<class K, class V> using absl_flat_hash_map =
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TSL_HOPSCOTCH
|
||||||
|
|
||||||
|
template<class K, class V> using tsl_hopscotch_map =
|
||||||
|
tsl::hopscotch_map<K, V, std::hash<K>, std::equal_to<K>, allocator_for<K, V>>;
|
||||||
|
|
||||||
|
template<class K, class V> using tsl_hopscotch_pg_map =
|
||||||
|
tsl::hopscotch_pg_map<K, V, std::hash<K>, std::equal_to<K>, allocator_for<K, V>>;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// fnv1a_hash
|
// fnv1a_hash
|
||||||
|
|
||||||
template<int Bits> struct fnv1a_hash_impl;
|
template<int Bits> struct fnv1a_hash_impl;
|
||||||
@ -363,6 +376,16 @@ template<class K, class V> using absl_flat_hash_map_fnv1a =
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TSL_HOPSCOTCH
|
||||||
|
|
||||||
|
template<class K, class V> using tsl_hopscotch_map_fnv1a =
|
||||||
|
tsl::hopscotch_map<K, V, fnv1a_hash, std::equal_to<K>, allocator_for<K, V>>;
|
||||||
|
|
||||||
|
template<class K, class V> using tsl_hopscotch_pg_map_fnv1a =
|
||||||
|
tsl::hopscotch_pg_map<K, V, fnv1a_hash, std::equal_to<K>, allocator_for<K, V>>;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -382,6 +405,13 @@ int main()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TSL_HOPSCOTCH
|
||||||
|
|
||||||
|
test<tsl_hopscotch_map>( "tsl::hopscotch_map" );
|
||||||
|
test<tsl_hopscotch_pg_map>( "tsl::hopscotch_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" );
|
||||||
@ -393,13 +423,20 @@ int main()
|
|||||||
test<absl_node_hash_map_fnv1a>( "absl::node_hash_map, FNV-1a" );
|
test<absl_node_hash_map_fnv1a>( "absl::node_hash_map, FNV-1a" );
|
||||||
test<absl_flat_hash_map_fnv1a>( "absl::flat_hash_map, FNV-1a" );
|
test<absl_flat_hash_map_fnv1a>( "absl::flat_hash_map, FNV-1a" );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TSL_HOPSCOTCH
|
||||||
|
|
||||||
|
test<tsl_hopscotch_map_fnv1a>( "tsl::hopscotch_map, FNV-1a" );
|
||||||
|
test<tsl_hopscotch_pg_map_fnv1a>( "tsl::hopscotch_pg_map, FNV-1a" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::cout << "---\n\n";
|
std::cout << "---\n\n";
|
||||||
|
|
||||||
for( auto const& x: times )
|
for( auto const& x: times )
|
||||||
{
|
{
|
||||||
std::cout << std::setw( 30 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
std::cout << std::setw( 31 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user