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

ASP.NET/SQL find the element ID and update database -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -