STL Map使用

来源:互联网 发布:微信支付php 完整源码 编辑:程序博客网 时间:2024/06/05 16:38
/*description:STL  map使用author:Jasondate:20160521*/#include<stdio.h>#include <map>#include<iostream>using namespace std;int main(){    map<char,int>  mymap;    int data[]={31,-41,59,26,-53,58,97,-93,-23,84,33,22};    int len=sizeof(data)/sizeof(data[0]);    cout<<"len="<<len<<endl;    for (int i=0;i<len;i++)    {        mymap.insert(pair<char,int>(char('a'+i),data[i]));    }    map<char,int>::iterator it;    for (it=mymap.begin(); it!=mymap.end(); ++it)    {        cout << it->first  <<" -> "<<it->second<<endl;    }    cout<<endl;    cout<<"max_size:"<<mymap.max_size()<<endl;    return 0;}

insert Insert elements (public member function )
erase
Erase elements (public member function )
swap
Swap content (public member function )
clear
Clear content (public member function )
emplace
Construct and insert element (public member function )
emplace_hint
Construct and insert element with hint (public member function )

0 0
原创粉丝点击