map
来源:互联网 发布:郑州淘宝加盟宣判了吗 编辑:程序博客网 时间:2024/05/18 03:02
1,map的构造map <string, int> mp;map<int ,string> mp;map<char,int> mp;第一个参数为关键字,不能相同。然后这个map自己本身是有序的,按照第一个关键字升序排列2.插入第一种:mp.insert(pair<string,int>("student",2));mp.insert(pair<string,int>("student",3));//用insert,但是如果map中出现了student 关键字的话,第二条就插不进去,此时mp[student]=2;第二种:mp["student"]=2;mp["student"]=3;//用数组来,然后就是直接覆盖了,此时 mp[student]=3 3. map <string, int> ::iterator it; for(it=mc1.begin();it!=mc1.end();it++) ans+=it->second; 如果是第一关键字的话,就是 it->first; 4.数据的查找 mp.count("student");//如果有的话,就返回1,没有的话就返回0 mp.find("student");//返回迭代器,出现的位置 5.map的清空
0 0
- map
- MAP
- map
- MAP
- map
- map
- map
- Map
- Map
- Map
- map
- map
- Map
- .map
- map
- MAP
- map
- Map
- linux安装redis服务
- liunx下mysql遇到的简单问题
- 跳跃表原理
- 类初始化顺序
- 真厉害!树莓派销量破1250万仅次于Windows、Mac
- map
- vagrant 基本命令、标准配置文件,支持nfs
- 静态块(变量)和非静态块(变量)
- tomcat服务器-重新部署后报错org.xml.sax.SAXParseException
- 微信支付开发教程JAVA编[006]-刷卡支付
- (Swift 实现)排序 —— 归并排序
- 程序员能找到高薪工作么 有哪些优势?
- 安卓动画插值器 Interpolator
- 对象属性和数组元素的初始默认值