(engineModules_.begin()+i) is only using an iterator because there's not other way of deleting something.
Well, then I can use iterators from the beginning anyway, makes it easier to switch to another container, because a list for example doesn't support
engineModules_.begin()+i
The pointer here is never used to access something in that function, so it shouldn't be able to make any problems.
But if it IS a null pointer then suddenly you could have a situation where (engineModules_[ i] == module) evaluates to TRUE when both are NULL and then everything goes to hell.
Well, if both are null at a completely valid position i, than that value is supposed to be removed at that position i, and it will be removed.
Could you further explain this?
Well the problem is simply that goign through a for loop to find something is always the least efficient way of doing it. It depends on how its used elsewhere and how often the remove funciton is being called. Usually when you are iterating through an array you need to consider whether or not it would be better as a linked list of some sort.
[/quote]
Ah, you don't mind the iterating itself, but the possible erase call that is inefficient with a vector (iterating through a list isn't faster).
Well, that's right, I could change it to a list, it's been a vector before that erase call got added.