int _tmain(int argc, _TCHAR* argv[])
{
std::map<int,std::map<int,int> > mapAll;
mapAll[1][1]=1;
mapAll[1][2]=2;
{
std::map<int,std::map<int,int> >::iterator it = mapAll.find(1);
if(it!=mapAll.end())
{
std::map<int,int>::iterator pos = it->second.find(1);
if(pos!=it->second.end())
{
pos->second = 9;
}
}
}
{
std::map<int,std::map<int,int> >::iterator it = mapAll.find(1);
if(it!=mapAll.end())
{
std::map<int,int>::iterator pos = it->second.find(1);
if(pos!=it->second.end())
{
it->second.erase(pos);
}
}
}
return 0;
}
对于std::map来说,其内部的值可通过多级iterator直接修改,不必像std::vector那样,使用(*it)来更新数据
文章评论