GridIterator
| Kind of class: | class |
|---|---|
| Inherits from: | Point |
| Implements: | |
| Version: | 1.0 |
| Author: | Francis Bourre |
| Classpath: | com.bourre.structures.GridIterator |
| File last modified: | Wednesday, 31 October 2007, 07:35:30 |
GridIterator iterates over an AbstractGrid data structure.Example
var g : NGrid : NGrid = new NGrid(2,2); var myIterator : Iterator = new GridIterator( g ); while( myIterator.hasNext() ) { var e : Number = myIterator.next(); }
Summary
Constructor
Instance methods
Instance methods inherited from Point
Constructor
GridIterator
function GridIterator (
g:AbstractGrid)
Usage : var i:GridIterator = new GridIterator(myGrid);
Parameters:
g:
target Grid for the iterator.
Instance methods
getIndex
function getIndex (
) : Number
Returns current iterator position in grid structure.
Example
var g : NGrid : NGrid = new NGrid(2,2); var myIterator : Iterator = new GridIterator( g ); while( myIterator.hasNext() ) { var e : Number = myIterator.next(); PixlibDebug.INFO( "Iterator index = " + myIterator.getIndex() ); }
Returns:
Number indexSpecified by:
hasNext
function hasNext (
) : Boolean
Indicates if the next iterator position exists.
Example
var g : NGrid : NGrid = new NGrid(2,2); var myIterator : Iterator = new GridIterator( g ); while( myIterator.hasNext() ) { // }
Returns:
true if next position exist, either falseSpecified by:
next
function next (
)
Increments iterator position and returns next object value.
Example
var g : NGrid : NGrid = new NGrid(2,2); var myIterator : Iterator = new GridIterator( g ); while( myIterator.hasNext() ) { var e : Number = myIterator.next(); }
Returns:
Grid element (relaxed type for Grid polymorphism)
Specified by:
toString
function toString (
) : String
Returns the string representation of this instance.
Returns:
the string representation of this instance
Overrides: