std::map
1.例:
map<int,string> m_mapTest;
m_mapTest.insert(make_pair(1,"kong"));
m_mapTest.insert(make_pair(2,"yang"));
m_mapTest.insert(make_pair(1,"hello1"));
m_mapTest.insert(make_pair(3,"hello3"));
m_mapTest.insert(make_pair(2,"hello2"));
map<int,string>::iterator it = m_mapTest.begin();
for(;it!=m_mapTest.end();it++)
{
string sTem = (*it).second;
::OutputDebugString(sTem.c_str());
::OutputDebugString("\n");
}
输出结果:
kong
yang
hello3
2.vector和map中的erase方法在linux平台和windows平台下的差异
std::map<
int
,
float
>::iterator itr;
for
(itr = i_f_map.begin(); itr != i_f_map.end(); itr = i_f_map.erase(itr));
// win32可用,linux 不可用
for
(itr = i_f_map.begin(); itr != i_f_map.end(); i_f_map.erase(itr++));
// linux,win32可用
std::map的更多相关文章
- C++ std::map
std::map template < class Key, // map::key_type class T, // map::mapped_type class Compare = less ...
- std::map用法
STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用. 在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...
- C++ std::map::erase用法及其陷阱
1.引入: STL的map中有一个erase方法用来从一个map中删除制定的节点 eg: map<string,string> mapTest; typedef map<string ...
- std::map的clear()没有用?
昨天晚上,我徒弟跑过来讲,他的程序的内存占用居高不下,愿意是std::map的clear()没有效果.于是我让他用erase(begin,end); 试试也不行. 代码如下: void release ...
- std::map的操作:插入、修改、删除和遍历
using namespace std; std::map<int,int> m_map; 1.添加 for(int i=0;i<10;i++) { m_map.insert(mak ...
- Using std::map with a custom class key
From: https://www.walletfox.com/course/mapwithcustomclasskey.php If you have ever tried to use a cus ...
- Std::map too few template arguments
在上述的代码中,红色波浪线的部分编译的时候报错: error C2976: 'std::map' : too few template arguments 换成std::map<std::str ...
- 使用std::map和std::list存放数据,消耗内存比实际数据大得多
使用std::map和std::list存放数据,消耗内存比实际数据大得多 场景:项目中需要存储一个结构,如下程序段中TEST_DATA_STRU,结构占24B.但是使用代码中的std::list&l ...
- STL之std::set、std::map的lower_bound和upper_bound函数使用说明
由于在使用std::map时感觉lower_bound和upper_bound函数了解不多,这里整理并记录下相关用法及功能. STL的map.multimap.set.multiset都有三个比较特殊 ...
随机推荐
- 缺陷跟踪系统Mantis Bug Tracker
缺陷管理平台Mantis,也做MantisBT,全称Mantis Bug Tracker. 项目在github的地址:https://github.com/mantisbt/mantisbt Mant ...
- jQuery.extend和jQuery.fn.extend的区别?
jquery 本身 是由 Resig: 莱希格, 一个美国的小伙子小伙伴开发的, 在2005年 prototype发表之后, 在2006年1月发表的, 后来进入mozilla工作, mozilla的j ...
- 请问如何查看mysql 的端口号?
mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +--------- ...
- 我的linux桌面
经过几次尝试安装linux系统之后,终于把自己的系统安装成了linux系统. wangkongming@ThinkPad-T410 ~ $ lsb_release -a No LSB modules ...
- Mysql CPU占用90%
今天网站打开卡,查了下发现Mysql CPU占用到90%! 1.通过putty工具连接mysql putty工具十分的强大,它可以让我们直接访问MySQL.当然,要实现这一步肯定要做点什么.MySQL ...
- WCF--提示:"未找到终结点。"
刚开始调用WCF的时候一直报错... ““System.ServiceModel.EndpointNotFoundException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进 ...
- mac jdk环境变量
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk ...
- 搭建 Linux 下 GitLab 服务器
转自:http://blog.csdn.net/passion_wu128/article/details/8216086 目录: 平台需求 硬件需求 本安装指南已于 DebianUbuntu 测试通 ...
- C#中页面之间传值传参的六种方法
QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中.如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法.但是对于传递数组或对象的话,就不能用这 ...
- WPF:类型转换器的实现
类型转换器提供字符串文本到值的转换方法来帮助WPF设计时在XAML中配置属性.具体用法可以参考MSDN的文档:如何:实现类型转换器. 下面是一个Demo,参考自<葵花宝典--WPF自学手册> ...