Packagecom.ericfeminella.utils.iterators
Classpublic class CollectionIterator
ImplementsIIterator

Concrete Iterator implementation which provides an API for traversing an ICollectionView

See also

mx.collections.ICollectionView
mx.collections.IList
mx.collections.CursorBookmark
mx.collections.IViewCursor


Protected Properties
 PropertyDefined by
  collection : ICollectionView
Defines the ICollectionView aggregate object instance
CollectionIterator
  cursor : IViewCursor
Defines the IViewCursor instance to the aggregate
CollectionIterator
Public Methods
 MethodDefined by
  
CollectionIterator(collection:ICollectionView = null)
Instantiates a new CollectionIterator instance
CollectionIterator
  
hasNext():Boolean
Determines if there are elements remaining in the ICollectionView
CollectionIterator
  
next():*
Returns the next item in the ICollectionView
CollectionIterator
  
position():int
Determines the IViewCursor position of the ICollectionView
CollectionIterator
  
reset():void
Resets the IViewCursor to a zero based indexed position
CollectionIterator
  
setAggregate(aggregate:Object = null):void
Sets the collection in which to iterate over
CollectionIterator
Property detail
collectionproperty
protected var collection:ICollectionView

Defines the ICollectionView aggregate object instance

cursorproperty 
protected var cursor:IViewCursor

Defines the IViewCursor instance to the aggregate

Constructor detail
CollectionIterator()constructor
public function CollectionIterator(collection:ICollectionView = null)

Instantiates a new CollectionIterator instance

Parameters
collection:ICollectionView (default = null) — collection in which to iterate over

Example
A simple CollectionIterator example is as follows:
         
      var collection:ICollectionView = new ArrayCollection(["A","B","C"]);
      var it:IIterator = new CollectionIterator( collection );
      
      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 ICollectionView

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 in the ICollectionView

Retrieves the next element in the aggregate

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

Determines the IViewCursor position of the ICollectionView

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 IViewCursor to a zero based indexed position

See also

mx.collections.CursorBookmark.FIRST
setAggregate()method 
public function setAggregate(aggregate:Object = null):void

Sets the collection in which to iterate over

Sets the aggregate object in which to iterator over

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