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

Popular posts from this blog

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -