Packagesystem.data.iterators
Classpublic class ArrayIterator
InheritanceArrayIterator Inheritance Object
Implements Iterator
Subclasses ArrayFieldIterator

Converts an Array to an iterator.

Example :

     import system.iterators.ArrayIterator ;
     import system.Iterator ;
     
     var ar:Array = ["item1", "item2", "item3", "item4"] ;
     var it:Iterator = new ArrayIterator(ar) ;
     
     while (it.hasNext())
     {
         trace (it.next()) ;
     }
     
     trace ("--- it reset") ;
     
     it.reset() ;
     while (it.hasNext()) 
     {
         trace (it.next() + " : " + it.key()) ;
     }
     
     trace ("--- it seek 2") ;
     
     it.seek(2) ;
     while (it.hasNext())
     {
         trace (it.next()) ;
     }
     
     trace ("---") ;
     



Protected Properties
 PropertyDefined By
  _a : Array
current array
ArrayIterator
  _k : Number
current key
ArrayIterator
Public Methods
 MethodDefined By
  
ArrayIterator(a:Array)
Creates a new ArrayIterator instance.
ArrayIterator
  
hasNext():Boolean
Returns true if the iteration has more elements.
ArrayIterator
  
key():*
Returns the current key of the internal pointer of the iterator (optional operation).
ArrayIterator
  
next():*
Returns the next element in the iteration.
ArrayIterator
  
remove():*
Removes from the underlying collection the last element returned by the iterator (optional operation).
ArrayIterator
  
reset():void
Reset the internal pointer of the iterator (optional operation).
ArrayIterator
  
seek(position:*):void
Changes the position of the internal pointer of the iterator (optional operation).
ArrayIterator
Property Detail
_aproperty
protected var _a:Array

current array

_kproperty 
protected var _k:Number

current key

Constructor Detail
ArrayIterator()Constructor
public function ArrayIterator(a:Array)

Creates a new ArrayIterator instance.

Parameters
a:Array — the array to enumerate with the iterator.

Throws
ArgumentError — If the the passed-in Array argument is 'null'.
Method Detail
hasNext()method
public function hasNext():Boolean

Returns true if the iteration has more elements.

Returns
Booleantrue if the iteration has more elements.
key()method 
public function key():*

Returns the current key of the internal pointer of the iterator (optional operation).

Returns
* — the current key of the internal pointer of the iterator (optional operation).
next()method 
public function next():*

Returns the next element in the iteration.

Returns
* — the next element in the iteration.
remove()method 
public function remove():*

Removes from the underlying collection the last element returned by the iterator (optional operation).

Returns
*
reset()method 
public function reset():void

Reset the internal pointer of the iterator (optional operation).

seek()method 
public function seek(position:*):void

Changes the position of the internal pointer of the iterator (optional operation).

Parameters

position:*