The question is incorrect and can only lead to a complex and ineffective answer. To get an iterator, you, of course, start with something iterative, which in most cases will offer a more direct way to access the last element.
Once you create an iterator from an iterable, you get stuck in the elements, because that is the only thing that provides an iteration.
Thus, the most effective and understandable way is not to create an iterator in the first place, but to use your own methods of accessing an iterable.
ludwig Jun 29 '10 at 2:37 a.m. 2010-06-29 02:37
source share