I won't have thought that you need to force people to adopt a particular style for this, there are usually far more important things to worry about. For what it is worth, my way of coding is like this:
IMO it is reasonable for a coding standard to mandate a particular style. I agree with Roger on the choice: 'for' is much better in this case. Consider the following:
There is a bug in this which is obvious when you're looking for it, but can be missed if you're not. That is, in the second while() loop, we're using the wrong iterator. This is often a copy/paste error - and not necessarily an obvious one one, since the iterator 'iter' has no more elements, so the second while() loop is silently skipped.
If this code is written using for() loops, the scope of the Iterator prevents this error from occurring.
That all said, this has nothing to do with performance...it's a matter of coding style
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
subject: Which loop is recommended for getting values from list?