mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 08:34:39 +08:00
revert incorrect change
This commit is contained in:
Executable → Regular
+24
-37
@@ -1,41 +1,28 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "parallel_hashmap/phmap.h"
|
||||
|
||||
|
||||
int main() {
|
||||
phmap::flat_hash_map<std::string, std::vector<std::string>> mymap;
|
||||
|
||||
//initialize mymap
|
||||
mymap["hitF"].push_back("hitF");
|
||||
mymap["hitB"].push_back("hitB");
|
||||
mymap["idleF"].push_back("idleF");
|
||||
mymap["idleB"].push_back("idleB");
|
||||
mymap["walkF"].push_back("walkF");
|
||||
mymap["walkB"].push_back("walkB");
|
||||
mymap["dyingF"].push_back("dyingF");
|
||||
mymap["dyingB"].push_back("dyingB");
|
||||
mymap["attackF"].push_back("attackF");
|
||||
mymap["attackB"].push_back("attackB");
|
||||
|
||||
//set fallbacks
|
||||
mymap["downB"] = mymap["idleB"];
|
||||
mymap["downF"] = mymap["idleF"];
|
||||
mymap["hit_upF"] = mymap["idleF"];
|
||||
mymap["hit_upB"] = mymap["idleB"];
|
||||
mymap["weakF"] = mymap["idleF"];
|
||||
mymap["weakB"] = mymap["idleB"];
|
||||
|
||||
//print map
|
||||
for(auto& element : mymap) {
|
||||
std::cout << element.first << ": ";
|
||||
for(auto& inner : element.second) {
|
||||
std::cout << inner;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <parallel_hashmap/phmap.h>
|
||||
|
||||
using phmap::flat_hash_map;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Create an unordered_map of three strings (that map to strings)
|
||||
flat_hash_map<std::string, std::string> email =
|
||||
{
|
||||
{ "tom", "tom@gmail.com"},
|
||||
{ "jeff", "jk@gmail.com"},
|
||||
{ "jim", "jimg@microsoft.com"}
|
||||
};
|
||||
|
||||
// Iterate and print keys and values
|
||||
for (const auto& n : email)
|
||||
std::cout << n.first << "'s email is: " << n.second << "\n";
|
||||
|
||||
// Add a new entry
|
||||
email["bill"] = "bg@whatever.com";
|
||||
|
||||
// and print it
|
||||
std::cout << "bill's email is: " << email["bill"] << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user