Packagecom.ericfeminella.utils.iterators
Classpublic class ArrayIterator
ImplementsIIterator

Concrete Iterator implementation which provides methods for iterating over an array



Public Methods
 MethodDefined by
  
ArrayIterator(array:Array = null)
Instantiates a new ArrayIterator instance
ArrayIterator
  
hasNext():Boolean
Determines if there are elements remaining in the aggregate
ArrayIterator
  
next():*
Returns the next item element in the array
ArrayIterator
  
position():int
Determines the indexed position of the aggreagate
ArrayIterator
  
reset():void
Resets the index of the ArrayIterator instance to 0
ArrayIterator
  
setAggregate(aggregate:Object = null):void
Sets the array in which the ArrayIterator instance is to iterator over
ArrayIterator
Constructor detail
ArrayIterator()constructor
public function ArrayIterator(array:Array = null)

Instantiates a new ArrayIterator instance

Parameters
array:Array (default = null) — Array in which to iterate over

Example
A basic ArrayIterator example is as follows:
         
      var array:Array = new Array("A","B","C");
      var it:IIterator = new ArrayIterator( array );
      
      while ( it.hasNext() )
      {
          trace( it.next(), it.position());
      }
      
      //outputs:
      //A, 0
      //B, 1
      //C, 2
      

Method detail
hasNext()method
public function hasNext():Boolean

Determines if there are elements remaining in the aggregate

Determines if there are elements remaining in the aggregate

Returns
Boolean — true if an element remains, false if not
next()method 
public function next():*

Returns the next item element in the array

Returns
* — Next array element based on the current index
position()method 
public function position():int

Determines the indexed position of the aggreagate

Determines the position of the current element in the aggreagate

Returns
int — the current index of the aggreagate
reset()method 
public function reset():void

Resets the index of the ArrayIterator instance to 0

setAggregate()method 
public function setAggregate(aggregate:Object = null):void

Sets the array in which the ArrayIterator instance is to iterator over

Sets the aggregate object in which to iterator over

Parameters
aggregate:Object (default = null) — aggregate instance