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. 问题 1923: [蓝桥杯][算法提高VIP]学霸的迷宫 (BFS)

    题目链接:https://www.dotcpp.com/oj/problem1923.html 题目描述 学霸抢走了大家的作业,班长为了帮同学们找回作业,决定去找学霸决斗.但学霸为了不要别人打扰,住在 ...

  2. Linux编译安装python3

    1.解决编译环境的,依赖环境,必须保证这里正确安装,方可执行后续步骤yum install gcc patch libffi-devel python-devel zlib-devel bzip2-d ...

  3. 刷Python核心编程第三版的习题时遇到一个findall的坑

    在用正则表达式做以下查找时,发现re.findall()对于正则表达式有没有圆括号是有区分的,具体如下 line = 'Tue Sep 18 12:48:21 2029::ilziuv@zcntzir ...

  4. 简易轮播图、内含定时器。熟练JS操作

    HTML部分: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF ...

  5. 深入理解 Java 多线程核心知识

    多线程相对于其他 Java 知识点来讲,有一定的学习门槛,并且了解起来比较费劲.在平时工作中如若使用不当会出现数据错乱.执行效率低(还不如单线程去运行)或者死锁程序挂掉等等问题,所以掌握了解多线程至关 ...

  6. 【Rice】Cultivar versus Variety

    From Cindy Haynes, Department of Horticulture   As a horticulturist, it is important that I use the ...

  7. Unity入门一,什么是GameObject,MonoBehaviour

    Unity入门一,什么是GameObject,MonoBehaviour GameObject和Component Unity是一个Component-Based的引擎,所有物体都是GameObjec ...

  8. 2019/4/15 wen 正则表达式

  9. Let’s Encrypt 通配符证书申请配置

    首先你可以查看下官方提供的支持申请通配符证书的客户端列表:https://letsencrypt.org/docs/client-options/. 这些客户端支持最新的ACME v2接口,而这个接口 ...

  10. RHCE

    RHCE 配置 配置firewalld防火墙 配置firewalld端口转发 自定义用户环境 配置链路聚合 配置IPV6地址 配置本地邮件服务