View Single Post
Old 12-04-2007, 02:12 AM   #6 (permalink)
slitz
euro scum
 
slitz's Avatar
 
Join Date: Aug 2002
Location: Sweden
Posts: 785
-6 Internets
Like Hachima so nicely showed, a Iterator can not give you a index nor can it find a specific object at a certain index. The reason is simple.
Iterator is just a object that goes through a collection to give you a "next" object. It's supposed to work on all collections, even randomAccessCollections, Sets etc, where the order is irrelevant, it can't give you a index since that would make the method or function invalid for other type of collections. Foreach loop uses a iterator, so you're not supposed to get the index when using a for each. If you want the index, use a normal for loop, since that is your own implementation.
slitz is offline   Reply With Quote

 
Uberguilds Network