zoukankan      html  css  js  c++  java
  • STL 小白学习(10) map

    map的构造函数

    map<int, string> mapS;

    数据的插入:用insert函数插入pair数据,下面举例说明

    mapStudent.insert(pair<int, string>(1, "student_one"));
    mapStudent.insert(pair<int, string>(2, "student_two")); 
    mapStudent.insert(pair<int, string>(3, "student_three"));  

    map迭代器

    map<int, string>::iterator iter;

    用法如法炮制

    for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++)  
      
           cout<<iter->first<<' '<<iter->second<<endl; 

    map查找

    mymap.find('a')->second

     map.find简单运用

    iter = mapStudent.find(1);
    if(iter != mapStudent.end())
    {
           Cout<<”Find, the value is ”<<iter->second<<endl;
    }
  • 相关阅读:
    【原】戏说Java
    git分支branch合并到主分支master
    环境搭建
    zookeeper简单实战
    zookeeper介绍
    临时表与中间表
    避免活跃性
    sss
    sss
    sss
  • 原文地址:https://www.cnblogs.com/likeghee/p/10668095.html
Copyright © 2011-2022 走看看