org.as2lib.core.BasicClass +--org.as2lib.data.holder.array.ArrayIterator
Iterator
ArrayIterator
can be used to iterate over arrays.
The usage of this iterator is quite simple. There is one method to check whether there are more elements left to iterate over hasNext, one method to get the next element next and one to remove the current element remove.
Example:
var iterator:Iterator = new ArrayIterator(["value1", "value2", "value3"]);
while (iterator.hasNext()) {
trace(iterator.next());
}
Output:
value1 value2 value3
public function ArrayIterator(target:Array)
Constructs a new ArrayIterator
instance.
target | the array to iterate over |
IllegalArgumentException | if the passed-in target array is
null or undefined
|
public function hasNext(Void):Boolean
Returns whether there exists another element to iterate over.
true
if there is at least one lement left to iterate over
public function next(Void)
Returns the next element of the array.
the next element of the array
NoSuchElementException | if there is no next element |
public function remove(Void):Void
Removes the currently selected element from this iterator and from the array this iterator iterates over.
IllegalStateException | if you try to remove an element when none is selected |