容器 MAP

1.equal_range

pair <myMapDef::iterator,myMapDef::iterator> myresult;

myPairDef ps=*MyMap1.begin();

myresult= MyMap1.equal_range(ps.first);//=====================================此处只接受键!不接受键值对!!!!!

ps=(*myresult.first); 

cout<<ps.first<<endl;

ps=(*myresult.second);

cout<<ps.first<<endl;

2.比较

struct SetCompare
{
bool operator()(const string &it1,const string &it2) const
{
if(it1 >it2)
{
return true;
}
else
return false;


}
};

typedef map <string,int,SetCompare> myMapDefComp;
myMapDefComp MyMapComp1;
};

但是map 所有操作都只能是键,不能是值!

原文地址:https://www.cnblogs.com/gaoxianzhi/p/3243423.html