-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpair_test.cpp
More file actions
61 lines (48 loc) · 1.64 KB
/
Copy pathpair_test.cpp
File metadata and controls
61 lines (48 loc) · 1.64 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
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <map>
#include <string>
int main(int argc, char* argv[]) {
std::map<std::string, std::string> fulldata;
std::pair<std::string, std::string> key_pair;
fulldata["name"] = "zhangsan";
fulldata["age"] = "1";
fulldata["address"] = "China";
fulldata["info"] = "...";
std::pair<std::string, std::string> tmp_pair("ext1", "no");
fulldata.insert(tmp_pair);
std::map<std::string, std::string>::iterator it = fulldata.begin();
for (; it != fulldata.end(); it++) {
key_pair = *it;
std::cout << key_pair.first << "-" << key_pair.second << std::endl;
}
/*
key_pair["name"] = "lisi";
key_pair["name_other"] = "lisier";
fulldata[key_pair] = 3;
key_pair["name"] = "san";
key_pair["name_other"] = "saner";
fulldata[key_pair] = 5;
key_pair["name"] = "zhang";
key_pair["name_other"] = "zhanger";
fulldata[key_pair] = 4;
key_pair["name"] = "wangwu";
key_pair["name_other"] = "wangwuer";
fulldata[key_pair] = 2;
std::pair<std::string, std::string> pair_target;
pair_target["name"] = "lisi";
pair_target["name_other"] = "lisier";
if (fulldata.find(pair_target) != fulldata.end()) {
std::cout << "found key, value is " << fulldata[pair_target] << std::endl;
} else {
std::cout << "not found" << std::endl;
}
pair_target["name"] = "maliu";
pair_target["name_other"] = "er";
if (fulldata.find(pair_target) != fulldata.end()) {
std::cout << "found key, value is " << fulldata[pair_target] << std::endl;
} else {
std::cout << "not found" << std::endl;
}
*/
return 0;
}