cleanup some warnings

This commit is contained in:
greg
2019-12-31 12:29:45 -05:00
parent 62f2c9ed97
commit 1d5651cffe
7 changed files with 100 additions and 41 deletions
+32 -16
View File
@@ -2,29 +2,45 @@
#include <string>
#include <parallel_hashmap/btree.h>
using phmap::btree_map;
using phmap::btree_set;
int main()
{
btree_map<std::string, int> persons =
// initialise map with some values using an initializer_list
phmap::btree_map<std::string, int> map =
{ { "John", 35 },
{ "Jane", 32 },
{ "Joe", 30 },
};
for (auto& p: persons)
std::cout << p.first << " (" << p.second << ")" << '\n';
// add a couple more values using operator[]()
map["lucy"] = 18;
map["Andre"] = 20;
// Create a btree_set of three floats (that map to strings)
using X = std::tuple<float, std::string>;
btree_set<X> email;
// Iterate and print keys and values
for (int i=0; i<10; ++i)
email.insert(X((float)i, "aha"));
map.insert(std::make_pair("Alex", 16));
map.emplace("Emily", 18); // emplace uses pair template constructor
for (auto& e: email)
std::cout << std::get<0>(e) << ", " << std::get<1>(e) << '\n';
return 0;
for (auto& p: map)
std::cout << p.first << ", " << p.second << '\n';
phmap::btree_map<int, std::string> map2;
map2.emplace(std::piecewise_construct, std::forward_as_tuple(0), std::forward_as_tuple(10, 'c'));
map2.try_emplace(1, 10, 'a'); // phmap::btree_map supports c++17 API
for (auto& p: map2)
std::cout << p.first << ", " << p.second << '\n';
// create a btree_set of tuples
using X = std::tuple<float, std::string>;
phmap::btree_set<X> set;
for (int i=0; i<10; ++i)
set.insert(X((float)i, std::to_string(i)));
set.emplace(15.0f, "15");
set.erase(X(1.0f, "1"));
for (auto& e: set)
std::cout << std::get<0>(e) << ", \"" << std::get<1>(e) << "\" \n";
return 0;
}