2019-06-15 19:50:43 -04:00
|
|
|
// Silly program just to test the natvis file for Visual Studio
|
|
|
|
|
// ------------------------------------------------------------
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "parallel_hashmap/phmap.h"
|
|
|
|
|
|
|
|
|
|
template<class Set, class F>
|
2020-11-29 09:58:09 -05:00
|
|
|
void test_set(const F &f)
|
2019-06-15 19:50:43 -04:00
|
|
|
{
|
|
|
|
|
Set s;
|
2019-06-15 19:54:11 -04:00
|
|
|
typename Set::iterator it;
|
2019-06-15 19:50:43 -04:00
|
|
|
for (int i=0; i<100; ++i)
|
|
|
|
|
s.insert(f(i));
|
|
|
|
|
|
|
|
|
|
it = s.begin();
|
|
|
|
|
++it;
|
|
|
|
|
|
|
|
|
|
it = s.end();
|
|
|
|
|
it = s.begin();
|
|
|
|
|
while(it != s.end())
|
|
|
|
|
++it;
|
|
|
|
|
it = s.begin();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 19:54:11 -04:00
|
|
|
int main(int, char **)
|
2019-06-15 19:50:43 -04:00
|
|
|
{
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
auto make_int = [](int i) { return i; };
|
|
|
|
|
auto make_string = [](int i) { return std::to_string(i); };
|
|
|
|
|
|
|
|
|
|
auto make_2int = [](int i) { return std::make_pair(i, i); };
|
|
|
|
|
auto make_2string = [](int i) { return std::make_pair(std::to_string(i), std::to_string(i)); };
|
2020-11-29 09:58:09 -05:00
|
|
|
|
2019-06-15 19:50:43 -04:00
|
|
|
|
|
|
|
|
test_set<phmap::flat_hash_set<int>>(make_int);
|
|
|
|
|
test_set<phmap::flat_hash_set<string>>(make_string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::node_hash_set<int>>(make_int);
|
|
|
|
|
test_set<phmap::node_hash_set<string>>(make_string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::flat_hash_map<int, int>>(make_2int);
|
|
|
|
|
test_set<phmap::flat_hash_map<string, string>>(make_2string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::node_hash_map<int, int>>(make_2int);
|
|
|
|
|
test_set<phmap::node_hash_map<string, string>>(make_2string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::parallel_flat_hash_set<int>>(make_int);
|
|
|
|
|
test_set<phmap::parallel_flat_hash_set<string>>(make_string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::parallel_node_hash_set<int>>(make_int);
|
|
|
|
|
test_set<phmap::parallel_node_hash_set<string>>(make_string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::parallel_flat_hash_map<int, int>>(make_2int);
|
|
|
|
|
test_set<phmap::parallel_flat_hash_map<string, string>>(make_2string);
|
|
|
|
|
|
|
|
|
|
test_set<phmap::parallel_node_hash_map<int, int>>(make_2int);
|
|
|
|
|
test_set<phmap::parallel_node_hash_map<string, string>>(make_2string);
|
2020-11-29 09:58:09 -05:00
|
|
|
|
|
|
|
|
// example of using default parameters in order to specify the mutex type
|
|
|
|
|
using Map = phmap::parallel_flat_hash_map<std::size_t, std::size_t,
|
2020-11-29 11:10:48 -05:00
|
|
|
std::hash<size_t>,
|
|
|
|
|
std::equal_to<size_t>,
|
2020-11-29 09:58:09 -05:00
|
|
|
std::allocator<std::pair<const size_t, size_t>>,
|
|
|
|
|
4,
|
|
|
|
|
std::mutex>;
|
|
|
|
|
auto make_2size_t = [](size_t i) { return std::make_pair(i, i); };
|
|
|
|
|
test_set<Map>(make_2size_t);
|
2019-06-15 19:50:43 -04:00
|
|
|
}
|