-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmap_test.cpp
More file actions
49 lines (38 loc) · 1.29 KB
/
Copy pathmap_test.cpp
File metadata and controls
49 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <map>
#include <string>
int main(int argc, char* argv[]) {
std::map<std::map<std::string, std::string>, int> fulldata;
std::map<std::string, std::string> key_map;
key_map["name"] = "zhangsan";
key_map["name_other"] = "zhangsaner";
fulldata[key_map] = 1;
key_map["name"] = "lisi";
key_map["name_other"] = "lisier";
fulldata[key_map] = 3;
key_map["name"] = "san";
key_map["name_other"] = "saner";
fulldata[key_map] = 5;
key_map["name"] = "zhang";
key_map["name_other"] = "zhanger";
fulldata[key_map] = 4;
key_map["name"] = "wangwu";
key_map["name_other"] = "wangwuer";
fulldata[key_map] = 2;
std::map<std::string, std::string> map_target;
map_target["name"] = "lisi";
map_target["name_other"] = "lisier";
if (fulldata.find(map_target) != fulldata.end()) {
std::cout << "found key, value is " << fulldata[map_target] << std::endl;
} else {
std::cout << "not found" << std::endl;
}
map_target["name"] = "maliu";
map_target["name_other"] = "er";
if (fulldata.find(map_target) != fulldata.end()) {
std::cout << "found key, value is " << fulldata[map_target] << std::endl;
} else {
std::cout << "not found" << std::endl;
}
return 0;
}