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并不涉及底层数据结构 ...
随机推荐
- ES6 模块的加载实现 import和export
ES6的Class只是面向对象编程的语法糖,升级了ES5的构造函数的原型链继承的写法,并没有解决模块化问题.Module功能就是为了解决这个问题而提出的. 历史上,JavaScript一直没有模块(m ...
- Java定义栈结构,实现入栈、出栈操作
package com.example.demo; import java.util.ArrayList; public class Stack { ArrayList<Object> l ...
- linux进程调度的算法
linux进程的调度算法 这节我们来学习一下linux进程的优先级 linux进程的优先级 进程提供了两种优先级,一种是普通的进程优先级,第二个是实时优先级,前者使用SCHEED_NORMAL调度策略 ...
- 代码报错--------EOFError: Compressed file ended before the end-of-stream marker was reached
背景:运行LeNet识别CIFAR-10的图像的代码时,报错: EOFError: Compressed file ended before the end-of-stream marker was ...
- OCP协议_电信特殊协议
OCP(Online Charging Protocol)协议——在线计费协议(也称为AAA协议),是中国电信(文中以中国电信为主)充分研究国内外在线计费协议,基于中国电信自己在线计费的需求,参考3G ...
- pidstat 命令(Linux 进程使用资源情况采样)
pidstat 作用 pidstat 获取服务器指定进程的使用资源信息(包括 CPU.设备IO.内存.线程.任务切换等). 执行一波 [root@wille ~]# pidstat Linux 2.6 ...
- 再提供一种解决Nginx文件类型错误解析漏洞的方法
[文章作者:张宴 本文版本:v1.2 最后修改:2010.05.24 转载请注明原文链接:http://blog.zyan.cc/nginx_0day/] 注:2010年5月23日14:00前阅读本文 ...
- php的异步非阻塞swoole模块使用(一)实现简易tcp服务器--客户端
//实例化一个swoole客户端 $swclient = new swoole_client(SWOOLE_SOCK_TCP); //建立连接---如果连接无效则退出 )){ echo "连 ...
- Robot Framework中ride.py打不开的解决方法
1.首先查看wxPython版本是否跟python的版本一致,一般都使用wxPython2.8-win64-unicode-2.8.12.1-py27.exe或者wxPython2.8-win32-u ...
- oracle 循环的一种写法
for v_n in( select bb.temNum, bb.LOANTYPE from (select decode(bns.assignstate, '{016D68F9-719B-4EFC- ...