[c++]stl map

映射和多重映射基于某一类型Key的键集的存在,提供对T类型的数据进行快速和高效的检索。

对map而言,键只是指存储在容器中的某一成员。

Map不支持副本键,multimap支持副本键。

Map和multimap对象包涵了键和各个键有关的值,键和值的数据类型是不相同的,这与set不同。

set中的key和value是Key类型的,而map中的key和value是一个pair结构中的两个分量。

Map<int, string> mapStudent;
mapStudent.insert(pair<int, string>(1, "student_one")); //插入
map<int, string>::iterator  iter;
for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++) //遍历
{  Cout<<iter->first<<" "<<iter->second<<end; }

mapStudent.insert(map<int, string>::value_type (1, "student_one")); //插入

map<int, string>::iterator iter;
iter = mapStudent.find(1);//查找
if(iter != mapStudent.end())
{ Cout<<"Find, the value is "<<iter->second<<endl; }

http://www.kuqin.com/cpluspluslib/20071231/3265.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值