ArrayEnumerator

Kind of class: public class
Package:
Inherits from:
Known subclasses:
Classpath: org.asaplibrary.data.array.ArrayEnumerator
File last modified: Sunday, 15 May 2011, 21:43:43
Straightforward enumeration (iterator) class for arrays. ArrayEnumerator has one way of iterating: forward (using getNextObject). For more options see TraverseArrayEnumerator.
Events broadcasted to listeners

Summary

Constructor
Instance methods
  • setObjects (inObjects:Array) : void
    • Stores a pointer to array inArray.
  • getCurrentObject () : *
    • Retrieves the object from the array at the current pointer location.
  • getNextObject () : *
    • Increments the location pointer by one and returns the object from the array at that location.
  • getAllObjects () : Array
    • Retrieves all objects.
  • reset () : void
    • Puts the enumerator just before the first array item.
  • getCurrentLocation () : int
  • setCurrentLocation (inLocation:int) : void
    • Sets the location pointer to a new position.
  • setCurrentObject (inObject:Object) : void
    • Sets the location pointer to the location (in the array) of inObject.

Constructor

ArrayEnumerator

function ArrayEnumerator(inObjects:Array = null)

Creates a new array enumerator. Optionally stores a pointer to array inArray.

Parameters
inArray:(optional) the array to enumerate

Instance methods

getAllObjects

override function getAllObjects() : Array

Retrieves all objects.

Returns
  • The array as set in the constructor or in setObjects.

getCurrentLocation

function getCurrentLocation() : int
Returns
  • The current position of the array location pointer.

getCurrentObject

override function getCurrentObject() : *

Retrieves the object from the array at the current pointer location.

Returns
  • (Deliberately untyped) The object from the array at the current pointer location.

getNextObject

override function getNextObject() : *

Increments the location pointer by one and returns the object from the array at that location.

Implementation note
Returns
  • (Deliberately untyped) The object at the new location. Returns null if the location pointer has moved past the end of the array.

reset

override function reset() : void

Puts the enumerator just before the first array item. At this point calling getCurrentObject will generate an error; you must first move the enumerator using getNextObject.

Implementation note

setCurrentLocation

function setCurrentLocation(inLocation:int) : void

Sets the location pointer to a new position.

Parameters
inLocation:the new pointer location
Implementation note

setCurrentObject

function setCurrentObject(inObject:Object) : void

Sets the location pointer to the location (in the array) of inObject.

Parameters
inObject:the object whose index the location pointer should point to
Implementation note

setObjects

function setObjects(inObjects:Array) : void

Stores a pointer to array inArray.

Parameters
inArray:the array to enumerate