map的构造函数

map<int, string> mapS;

数据的插入:用insert函数插入pair数据,下面举例说明

mapStudent.insert(pair<int, string>(, "student_one"));
mapStudent.insert(pair<int, string>(, "student_two"));
mapStudent.insert(pair<int, string>(, "student_three"));

map迭代器

map<int, string>::iterator iter;

用法如法炮制

for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++)  

       cout<<iter->first<<' '<<iter->second<<endl; 

map查找

mymap.find('a')->second

map.find简单运用

iter = mapStudent.find();
if(iter != mapStudent.end())
{
Cout<<”Find, the value is ”<<iter->second<<endl;
}

STL 小白学习(10) map的更多相关文章

  1. STL初步学习(map)

    3.map map作为一个映射,有两个参数,第一个参数作为关键值,第二个参数为对应的值,关键值是唯一的 在平时使用的数组中,也有点类似于映射的方法,例如a[10]=1,但其实我们的关键值和对应的值只能 ...

  2. C++ STL源代码学习(map,set内部heap篇)

    stl_heap.h ///STL中使用的是大顶堆 /// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap ...

  3. STL 小白学习(1) 初步认识

    #include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm ...

  4. STL 小白学习(9) 对组

    void test01() { //构造方法 pair<, ); cout << p1.first << p1.second << endl; pair< ...

  5. STL 小白学习(8) set 二叉树

    #include <iostream> using namespace std; #include <set> void printSet(set<int> s) ...

  6. STL 小白学习(7) list

    #include <iostream> using namespace std; #include <list> void printList(list<int>& ...

  7. STL 小白学习(5) stack栈

    #include <iostream> #include <stack> //stack 不遍历 不支持随机访问 必须pop出去 才能进行访问 using namespace ...

  8. STL 小白学习(6) queue

    //queue 一端插入 另一端删除 //不能遍历(不提供迭代器) 不支持随机访问 #include <queue> #include <iostream> using nam ...

  9. STL 小白学习(4) deque

    #include <iostream> #include <deque> //deque容器 双口 using namespace std; void printDeque(d ...

随机推荐

  1. Tomcat 控制台UTF-8乱码问题

    1.修改cmd的编码格式 快捷键win+R打开运行程序,输入regedit打开注册表,找到以下路劲并且修改. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Comman ...

  2. linux install Openvino

    recommend centos7 github Openvino tooltiks 1. download openvino addational installation for ncs2 ncs ...

  3. 解决js的 Math取正弦值 余弦值不准确的问题

    //角度 var  vAngle=90: //正弦值 var vSin=Math.round(Math.sin((vAngle * Math.PI/180)) * 1000000) / 1000000 ...

  4. Bigger-Mai 养成计划,Python基础巩固四

    一.装饰器:定义:本质是函数,(装饰其他函数)就是为其他函数添加附加功能.原则:1.不能修改被装饰的函数的源代码 2.不能修改被装饰函数的调用方式实现装饰器的知识储备:1.函数即‘变量’2.高阶函数 ...

  5. week1总结

    week1总结 1. 开发上线工具流程以及规范类 规范: css注释:/* Comment Text*/ Css嵌套选择器:请不要让嵌套选择器的深度超过 3 层! 再说一遍: 永远不要嵌套 ID 选择 ...

  6. [转载]使用IEDriverServer.exe驱动IE11,实现自动化测试

    转自:https://www.cnblogs.com/feiquan/p/8531618.html 下载地址: http://dl.pconline.com.cn/download/771640-1. ...

  7. 实验九 FBG 团队项目需求改进与系统设计

    任务一 A.<项目需求规格说明书>分析 根据老师的指导以及本周所学的OOA,分析改进上周编写的<项目需求规格说明书>,发现需求项目书UML图例描述不够完善,仅仅是用例图没办法更 ...

  8. PHP 如何获取客户端ip地址

    PHP 如何获取客户端ip地址 一.总结 一句话总结:主要是使用$_SERVER的 REMOTE_ADDR 和 HTTP_X_FORWARDED_FOR 两个属性,在用户使用不同代理的时候这两个属性可 ...

  9. Spring Boot 配置加载顺序详解

    使用 Spring Boot 会涉及到各种各样的配置,如开发.测试.线上就至少 3 套配置信息了.Spring Boot 可以轻松的帮助我们使用相同的代码就能使开发.测试.线上环境使用不同的配置. 在 ...

  10. vue eventBus使用

    类似于iframe之间的possMessage方式传参 1.eventBus.js文件 //用于兄弟组件通信 import Vue from 'vue'; export default new Vue ...