一个QMap对象: QMap<Ccountry> mapCountry, 保存着许多国家(Ccountry类)
我想遍历之,删除掉人口少于1万的国家
代码:
QMap<Ccountry>::Iterator it;
for( it = mapCountry.begin(); it != mapCountry.end(); ++it)
{
if( (*it).totalPeople < 10000 )
mapCountry.remove( it );
}
不知道这样做行不行?remove会不会影响到 iterator?