c++ - How to modify key values in std::map container -
given
std::map<int,std::string> mymap; fillmymapwithstuff(mymap); // modify key values - need add constant value each key (std::map<int,std::string>::iterator mi=mymap.begin(); mi != mymap.end(); ++mi) { // ... }
whats way apply re-indexing? must remove old entry , add new 1 new key , old value?
looks better off building new map , swapping afterward. you'll have n
insert operations instead of n
deletions , n
insertions.
Comments
Post a Comment