listsstacksand queues template void removeeveryotheritemcontainer lst auto itr lst begin)/itr is container::iterator whileitr !lst enditr lst eraseitr )ifitr !lst end++itrfigure using iterators to remove every other item in list (either vector or listefficient for listbut not for vector timing information the function template is shown in figure the use of auto at line is ++ feature that allows us to avoid the longer type container::iterator if we run the codepassing listit takes sec for , -item listand sec for an , , -item listand is clearly linear-time routinebecause the running time increases by the same factor as the input size when we pass vectorthe routine takes almost five minutes for an , -item vector and about twenty minutes for an , , -item vectorthe four fold increase in running time when the input increases by only factor of two is consistent with quadratic behavior const_iterators the result of *itr is not just the value of the item that the iterator is viewing but also the item itself this distinction makes the iterators very powerful but also introduces some complications to see the benefitsuppose we want to change all the items in collection to specified value the following routine works for both vector and list and runs in linear time it' wonderful example of writing generictype-independent code template void changecontainer cconst object newvalue typename container::iterator itr begin)whileitr ! end*itr+newvalueto see the potential problemsuppose the container was passed to routine using callby-constant reference this means we would expect that no changes would be allowed to cand the compiler would ensure this by not allowing calls to any of ' mutators consider the following code that prints list of integers but also tries to sneak in change to the list