1 #include2 #include 3 //查询性能最高 4 //允许重复的,hash_map 5 #include 6 #include 7 using namespace std; 8 9 10 void main()11 {12 //允许重复的映射13 unordered_multimap mymap{ { "a1",113},{ "a2",143 },{ "a3",1123 } };14 15 mymap.insert(pair ("a4", 345));16 mymap.insert(pair ("a4", 315));17 mymap.insert(pair ("a4", 325));18 mymap.insert(pair ("a4", 335));19 20 /*mymap.insert(unordered_multimap ::value_type("a5", 3425));*/21 22 /*for (auto i : mymap)23 {24 cout << i.first << " " << i.second << endl;25 }*/26 27 /*auto it = mymap.find("a1");28 if (it != mymap.end())29 {30 cout << it->second << endl;31 }*/32 33 //查找所有34 auto it = mymap.equal_range("a4");35 36 for_each(it.first, it.second, [](unordered_multimap ::value_type &x) {cout << x.first << " " << x.second << endl; });37 cin.get();38 }