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. Load data local infile 实验报告

    1.实验内容: 利用SQL语句“load data local infile”将“pet.txt”文本文件中的数据导入到mysql中 (pet表在数据库menagerie中) 2.实验过程及结果: ( ...

  2. MB SD Connect 5 vs 2017 FVDI2 Commander

    Both MB SD C5 and FVDI II are diagnostic and Programmer tools for Mercedes Benz Cars & Trucks.Th ...

  3. ubuntu 17.10 安装mvn

    首先,我用的系统是Ubuntu17.10,编辑器用的 vim ,Maven以 3.5.0为例 第一步,去官网下载maven. 官网下载页面.png 第二步,解压到/opt/maven目录(我安装在这个 ...

  4. golang rc4加密

    package main import "crypto/rc4" import "fmt" func main() { key := []byte(" ...

  5. 算法(第四版)C# 习题题解——2.1

    写在前面 整个项目都托管在了 Github 上:https://github.com/ikesnowy/Algorithms-4th-Edition-in-Csharp 这一节内容可能会用到的库文件有 ...

  6. topcoder srm 625 div1

    problem1 link 假设第$i$种出现的次数为$n_{i}$,总个数为$m$,那么排列数为$T=\frac{m!}{\prod_{i=1}^{26}(n_{i}!)}$ 然后计算回文的个数,只 ...

  7. 16_Linux网络配置

    A类:255.0.0.0        8 0 000 0001 - 0 111 1111 127用户回环,1-126 2^7-1个A类地址 容纳多少个主机:2^24-2 主机位全0:网络地址 主机位 ...

  8. Vue-admin工作整理(二):项目结构个人配置

    通过上一篇文章(Vue-admin工作整理(一):项目搭建)操作完毕后,基础项目已经搭建,下面就要对项目本身进行一下项目结构调整来符合自己的项目要求 1.首先要对package.json文件进行调整, ...

  9. vue_全局注册过滤器

    在一个项目中, 某些过滤器全局都有可能用的到, 统一管理并自动化全局注册是很方便的. 代码如下, 后续只需要在src/filters/index.js中添加方法就可以全局使用过滤器了. // src/ ...

  10. 实验七 《FBG》—-小学生课后习题答案原型设计

    一.实验目的与要求 1.掌握软件原型开发技术 2.学习使用软件原型开发工具 二.实验内容与步骤 1.开发工具: 使用的工具:墨刀(APP端开发原型) 工具简介: 墨刀(MockingBot)是一款简单 ...