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并不涉及底层数据结构 ...
随机推荐
- 欧拉系统-登陆 SSH 出现 Access Denied 错误
1./home 权限问题如果 /home 只支持 root 访问,那么不妨试一下 /tmp ,然后用 mv 命令再转移 2./etc/ssh/sshd_config 配置问题 vi /etc ...
- Linux安装Redis、PHP安装Redis扩展模块
Redis的官方下载: http://redis.io/download 步骤一:下载安装包 步骤二:编译源程序 步骤三:移动文件.便于管理 步骤四:启动 Redis服务 查看是否启动成功 ...
- 常用的商业级和免费开源Web漏洞扫描工具
Scanv 国内著名的商业级在线漏洞扫描.可以长期关注,经常会有免费活动.SCANV具备自动探测发现无主资产.僵尸资产的功能,并对资产进行全生命周期的管理.主动进行网络主机探测.端口探测扫描,硬件特性 ...
- python 教程(一)
必须感慨一下,整了一周多的时间才基本理通顺.自己老是不能静心,方法也不对所以走了很多弯路. 1.建议:一定要先去看官方文档. 下面我们来看一周的成果吧: windows下如何下载并安装Python 3 ...
- vps 11步移站步骤笔记
移站是经常的事,现在把步骤写上,防止忘记命令 1.登录SSH 2.打包数据库,phpmyadmin中备份数据库,导入新数据库,数据库中域名链接进行相应替换 获取phpmyadmin root密码 ca ...
- Gym - 101915D Largest Group 最大团
给你一个二分图 问你最大团为多大 解一:状压DP 解二:二分图最大匹配 二分图的最大团=补图的最大独立集 二分图最大独立集=二分图定点个数-最大匹配 //Hungary #include<bit ...
- Oracle 导入dump
1. 准备好.dmp文件
- Daily Affirmations 每天对自己大声说:我很棒
I was 18 the first time a therapist2) tried to get me to embrace the idea of daily affirmations. I w ...
- 快读代码level.2
long long read() { long long ans=0; char last=' ',ch=getchar();//last用来存正负号,并消去那些换行符,空格 ') { last=ch ...
- django初步--+urls解析
1.静态文件配置: 你在浏览器中输入网址能够有响应的资源返回给你 是因为后端已经提前给你开设该资源的接口,也就意味着你所能 访问到的资源 都是人家事先定义好的. 2.django如何给用户开设资源接口 ...