21.hash_map(已被废弃不再使用 被unordered_map代替)

 1 #include <string>
 2 //老版本的unordered_map(已经废弃不再使用)
 3 #include <hash_map>
 4 #include <iostream>
 5 using namespace std;
 6 
 7 
 8 void main()
 9 {
10     //允许重复的映射
11     hash_map<string, double>mymap{ { "a1",113 },{ "a2",143 },{ "a3",1123 } };
12 
13     mymap.insert(pair<string, double>("a4", 345));
14     mymap.insert(pair<string, double>("a4", 315));
15     mymap.insert(pair<string, double>("a4", 325));
16     mymap.insert(pair<string, double>("a4", 335));
17 
18     
19 
20     for (auto i : mymap)
21     {
22     cout << i.first << "  " << i.second << endl;
23     }
24 
25     cin.get();
26 }

 

转载于:https://www.cnblogs.com/xiaochi/p/8629698.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值