I'm writing some code that has a lot of substitution.
There's a list<char> productions which has a bunch of characters in it.
I repeatedly need to replace every character in productions with the rules corresponding to it in a map<char,char*> productionRules. So every character in productions might be replaced by zero or more characters as indicated by productionRules.
I'm thinking there's 2 ways to do it:
iterate over productions and .insert() all replacement characters in productions before .erase()'ing each element
Create a NEW list<char> newProductions then reassign productions to refer to newProductions.
Which is better? To .insert() and .erase() a whole lot or to just create a new one?