zoukankan      html  css  js  c++  java
  • 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(" ");
    }

    输出结果:

    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++));     // win32,linux均可用
     linux操作系统下使用itr = map.erase(itr)编译不过去,erase返回值为空。
      

     std::vector<int> vecTestList;

     for(std::vector<int>::iterator it = vecTestList.begin(); it != vecTestList.end(); it = vecTestList.erase(it));  //win32可用,linux可用

     for(std::vector<int>::iterator it = vecTestList.begin(); it != vecTestList.end(); vecTestList.erase(it++));   //win32不可用,linux不可用

     linux操作系统下使用vector.erase(it++);循环删除列表的过程中第一次循环删除没有问题,第二次循环删除会异常。

    3.map<,<> >在linux下需要有一个空格

  • 相关阅读:
    Oracle SQL性能优化
    readystate, 异步
    DOMContentLoaded
    有限状态机(Finite-state machine)
    APPcache
    读取上传文件内容
    drag file upload xhr 拖拽异步上传文件
    web worker
    页面性能测试
    闭包用法,延迟tab
  • 原文地址:https://www.cnblogs.com/justkong/p/4782750.html
Copyright © 2011-2022 走看看