C++ Map实践
实践如下:
#include <iostream>
#include <map>
#include <string>
#include <typeinfo>
using namespace std; int main() {
cout << "Map 测试" << endl; //int i =1;
string name("jack");
pair<int, string> pair1(, name);
pair<int, string> pair2(, "老张"); map<int, string> map1;
map1.insert(pair1);
map1.insert(pair1);
map1.insert(pair2); map<int, string>::iterator it;
for (it = map1.begin(); it != map1.end(); it++) {
cout << (*it).first << "->" << (*it).second << endl;
} pair<string, string> pair21("张三", "张三");
pair<string, string> pair22("老张", "老张"); map<string, string> map2;
map2.insert(pair21);
map2.insert(pair21);
map2.insert(pair22); map<string, string>::iterator it2;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} map2.erase("张三");
cout << "再次遍历" << endl;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} map2.insert(pair<string, string>("老张2", "老张2"));
cout << "再次遍历2" << endl;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} cout << "测试结束" << endl;
return ;
}
C++ Map实践的更多相关文章
- mybatis oracle 插入自增记录 获取主键值 写回map参数
网上搜了好多文章照着弄都返回不了主键给map, 实践证明要在传入的map参数里写回插入的主键,要这样写 <selectKey resultType="java.lang.Integer ...
- Python笔记(二)
python笔记 函数式编程 函数 函数是Python内建支持一种封装(将大段代码拆成函数) 通过函数的调用,可以将复制的任务分解. 函数式编程(Functional Programming) 计算机 ...
- C++ Primer 学习笔记_35_STL实践与分析(9)--map种类(在)
STL实践与分析 --map类型(上) 引: map是键-值对的集合. map类型通常能够理解为关联数组:能够通过使用键作为下标来获取一个值,正如内置数组类型一样:而关联的本质在于元素的值与某个特定的 ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example 1.4 Labeling the Map
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example 1.4 Labeling the Map 一.前言 MapServer拥有非常灵活的标签 ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers 一.前言 上一篇博客< ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.1 A map with single layer
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.1 A map with single layer 一.前言 开始MapServer用 ...
- 『实践』百度地图给map添加右键菜单(判断是否为marker)
var map; var s;//经度 var w;//纬度 $(document).ready(function(){ $(".mune").load("jsp/c ...
- golang 多维哈希(map,hashmap)实践随笔
有些场景使用多维哈希来存储数据,时间复杂度恒定,简单粗暴好用.这里记录一下. 如下是三维哈希的简单示意图,建议层数不要太多,否则时间久了,自己写的代码都不认识. 下图是三维哈希在内存的存储形式,has ...
- Golang高效实践之array、slice、map
前言 Golang的slice类型为连续同类型数据提供了一个方便并且高效的实现方式.slice的实现是基于array,slice和map一样是类似于指针语义,传递slice和map并不涉及底层数据结构 ...
随机推荐
- Hyperledger Fabric 环境搭建(2)
上一篇https://www.cnblogs.com/xdyixia/p/11738096.html 介绍了Hyperledger Fabric环境中各种软件安装和源码编译,这一篇介绍快速运行一个简单 ...
- OpenSSL源码简介
1.X.509标准 x509是由国际电信联盟(ITU-T)制定的数字证书标准:包含公钥和用户标志符.CA等: x509是数字证书的规范,P7和P12是两种封装形式:X.509是常见通用的证书格式.所有 ...
- Linux 文件恢复(XFS & EXT4)
在Linux中,删除rm命令使用需谨慎,有时候可能由于误操作,导致重要文件删除了,这时不要太紧张,操作得当的话,还是可以恢复的. EXT 类型文件恢复 删除一个文件,实际上并不清除inode节点和bl ...
- Qt5.12.0交叉编译
Qt5.12.0 交叉编译 源码配置 修改 qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf 文件 MAKEFILE_GENERATOR = UNIX C ...
- Spring Boot整合拦截器
过滤器和监听器都属于Servlet 的api,还可以使用 Spring 提供的拦截器(HandlerInterceptor)进行改更精细的控制.
- C++ Primer 第 5 版 习题参考答案
从 5 月初 - 8 月 16 日,每天基本都在啃 C++ 的语法.起初直接看C++ Primer 中文版(第 5 版),发现后边的章节看着很吃力.所以就转而看了清华大学郑莉老师和李超老师的视频C++ ...
- UVA - 11996 Jewel Magic (Treap+二分哈希)
维护一个01序列,一共四种操作: 1.插入一个数 2.删除一个数 3.反转一个区间 4.查询两个后缀的LCP 用Splay或者Treap都可以做,维护哈希值,二分求LCP即可. 注意反转序列的时候序列 ...
- vue - router + iView 的使用(简单例子)
所使用的工具:谷歌浏览器.Nodejs(自带npm).HBuilder 0.要先安装Nodejs,下载安装即可 0-1.安装vue-cli,打开cmd 输入 npm install -g @vue/c ...
- python 的ConfigParser模块
Python 之ConfigParser模块 一.ConfigParser简介 ConfigParser 是用来读取配置文件的包.配置文件的格式如下:中括号“[ ]”内包含的为section.sect ...
- SQL server 获取异常
一.try...... catch 获取异常信息 /*======================================== 相关错误消 息如下: ERROR_NUMBER() 返回错误号. ...