/*
description:
STL map使用
author:Jason
date: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 )