An iterator over a collection

Same as typedef Iterator but with an extra this.reset() and this.remove() method.

Methods

hasNext ():Bool

Returns true if this iteration has more elements.

See:

next ():T

Returns the next element in this iteration.

See:

remove ():Void

Removes the last element returned by the iterator from the collection.

Example:

var c:Collection<String> = new Array2<String>(...);
var itr = c.iterator();
while (itr.hasNext()) {
    var val = itr.next();
    itr.remove(); //removes val
}
trace(c.isEmpty()); //true

reset ():Itr<T>

Resets this iteration so the iterator points to the first element in the collection.

Improves performance if an iterator is frequently used.

Example:

var c:Collection<String> = new Array2<String>(...);
var itr = c.iterator();
for (i in 0...100) {
    itr.reset();
    for (element in itr) {
        trace(element);
    }
}