Class org.as2lib.data.holder.array.ArrayIterator

org.as2lib.core.BasicClass
   +--org.as2lib.data.holder.array.ArrayIterator

Implemented Interfaces

Iterator

Description

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
 

Method Index

new ArrayIterator()

hasNext(), next(), remove()

Inherited from BasicClass

toString()

Constructor Detail

ArrayIterator

public function ArrayIterator(target:Array)

Constructs a new ArrayIterator instance.

Parameters

targetthe array to iterate over

Throws

IllegalArgumentExceptionif the passed-in target array is null or undefined

Method Detail

hasNext

public function hasNext(Void):Boolean

Returns whether there exists another element to iterate over.

Return

true if there is at least one lement left to iterate over

Specified By

hasNext() in org.as2lib.data.holder.Iterator

next

public function next(Void)

Returns the next element of the array.

Return

the next element of the array

Throws

NoSuchElementExceptionif there is no next element

Specified By

next() in org.as2lib.data.holder.Iterator

remove

public function remove(Void):Void

Removes the currently selected element from this iterator and from the array this iterator iterates over.

Throws

IllegalStateExceptionif you try to remove an element when none is selected

Specified By

remove() in org.as2lib.data.holder.Iterator