STL 小白学习(10) map
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的更多相关文章
- STL初步学习(map)
3.map map作为一个映射,有两个参数,第一个参数作为关键值,第二个参数为对应的值,关键值是唯一的 在平时使用的数组中,也有点类似于映射的方法,例如a[10]=1,但其实我们的关键值和对应的值只能 ...
- C++ STL源代码学习(map,set内部heap篇)
stl_heap.h ///STL中使用的是大顶堆 /// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap ...
- STL 小白学习(1) 初步认识
#include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm ...
- STL 小白学习(9) 对组
void test01() { //构造方法 pair<, ); cout << p1.first << p1.second << endl; pair< ...
- STL 小白学习(8) set 二叉树
#include <iostream> using namespace std; #include <set> void printSet(set<int> s) ...
- STL 小白学习(7) list
#include <iostream> using namespace std; #include <list> void printList(list<int>& ...
- STL 小白学习(5) stack栈
#include <iostream> #include <stack> //stack 不遍历 不支持随机访问 必须pop出去 才能进行访问 using namespace ...
- STL 小白学习(6) queue
//queue 一端插入 另一端删除 //不能遍历(不提供迭代器) 不支持随机访问 #include <queue> #include <iostream> using nam ...
- STL 小白学习(4) deque
#include <iostream> #include <deque> //deque容器 双口 using namespace std; void printDeque(d ...
随机推荐
- springmvc配置之mvc:annotation-driven
为了简化springmvc配置,spring同时引入了mvc namespace, 配置了 <mvc:annotation-driven/> spring会默认注册a RequestMap ...
- ABP入门系列之2——ABP模板项目
进入官网下载模板项目 依次按下图选择: 输入验证码开始下载 下载提示: 二.启动项目 使用VS2017打开项目,还原Nuget包: 设置以Web结尾的项目,设置为启动项目: 打开Web.config, ...
- Maven Webapp项目web.xml版本记录
web.xml 2.0版本 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3// ...
- redis恢复(aof)
----------------redis备份恢复方法-----------------------------1.采用aof恢复方法若appendonly设置为no的情况下,在每个节点上执行bgre ...
- Android系统分析之运营商显示流程分析之运营商信息的读取流程二
运营商显示流程分析之运营商信息的读取流程 一. SIM卡运营商信息的读取 从前面的 运营商信息的获取和赋值 可以知道SIM卡运营商的赋值最终是在 SIMRecords 中完成的, 而SIM卡信息的相关 ...
- 8、Dockerfile详解
除了init之外,每一个进程都应该是其他进程的子进程(init是内核启动的),当手动启动nginx时,那么这个nginx就以shell子进程存在.当打开一个命令行提示符时,这个就相当于在运行一个she ...
- 《Clean Code》阅读笔记
Chapter 2 命名 命名要表现意图 避免歧义和误导,增强区分 命名可读性:便于发音,增强印象,便于交流 命名可查性:增强区分,便于搜索 类和对象的命名:名词或名词短语 方法的命名:动词或动词短 ...
- python中一个汉字点3个字节? utf-8
今天发现了一个汉字占了3个字节,一开始以为是两个呢,字符串切片时总出现乱码,后来才发现一个中文占3个字节.这才解决了乱码问题 原来 1. utf-8 编码中,一个汉字占三个字节.英文字母是一个占用一 ...
- 【转】 glibc detected *** corrupted double-linked list:错误的原因有如下三种可能
一个多线程的大程序运行的时候崩掉了,屏幕上打出这个: *** glibc detected *** corrupted double-linked list: 0xb78381d8 *** 三个原 ...
- python爬取某站磁力链
不同磁力链网站网页内容都不同,需要定制 1,并发爬取 并发爬取后,好像一会就被封了 import requests from lxml import etree import re from conc ...