ArrayEnumerator
| Kind of class: | class |
|---|---|
| Inherits from: | Enumerator < Dispatcher |
| Known subclasses: | |
| Author: | Arthur Clemens |
| Classpath: | org.asapframework.data.array.ArrayEnumerator |
| File last modified: | Thursday, 12 October 2006, 11:19:40 |
Straightforward enumeration (iterator) class for arrays. ArrayEnumerator has one way of iterating: forward (getNextObject). For more options see TraverseArrayEnumerator.
Events broadcasted to listeners:
- TraverseArrayEnumeratorEvent with type:
UPDATEIf the delegate validation method exists and only if the delegate method returns true.- (null)
Summary
Constructor
- ArrayEnumerator (inArray:Array)
- Creates a new array enumerator.
Instance properties
Instance properties inherited from Dispatcher
Instance methods
- setArray (inArray:Array) : Void
- Stores a pointer to array inArray.
- getCurrentObject
- getNextObject
- setCurrentLocation (inLocation:Number) : 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.
- getAllObjects : Array
- Retrieves all objects.
- reset : Void
- Puts the enumerator just before the first array item.
- update (inLocation:Number)
- Updates the location pointer to a new index location.
- findLocationForObject (inObject:Object) : Number
- Retrieves the array index location of item inObject.
Instance methods inherited from Enumerator
Constructor
ArrayEnumerator
function ArrayEnumerator (
inArray:Array)
Creates a new array enumerator. Optionally stores a pointer to array inArray.
Parameters:
inArray:
(optional) the array to enumerate
Instance properties
mArray
private mArray:Array
(read)
Pointer to external array.
mLocation
private mLocation:Number
(read)
Instance methods
findLocationForObject
private function findLocationForObject (
inObject:Object) : Number
Retrieves the array index location of item inObject.
Parameters:
inObject:
the object to be found
Returns:
- The array index location of item inObject. Returns -1 when the object is not found.
getAllObjects
function getAllObjects (
) : Array
Retrieves all objects.
Returns:
- The array as set in the constructor or in setArray.
getCurrentObject
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
function getNextObject (
)
Increments the location pointer by one and returns the object from the array at that location.
Returns:
- (Deliberately untyped) The object at the new location. Returns null if the location pointer has moved past the end of the array.
Implementation note:
- Calls update.
reset
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:
- Calls update.
Overrides:
setArray
function setArray (
inArray:Array) : Void
Stores a pointer to array inArray.
Parameters:
inArray:
the array to enumerate
setCurrentLocation
function setCurrentLocation (
inLocation:Number) : Void
Sets the location pointer to a new position.
Parameters:
inLocation:
the new pointer location
Implementation note:
- Calls update.
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:
- Calls update.
update
private function update (
inLocation:Number)
Updates the location pointer to a new index location.
Parameters:
inLocation:
the new index location
Events broadcasted to listeners:
- TraverseArrayEnumeratorEvent with type:
UPDATEIf the delegate validation method exists and only if the delegate method returns true.- (null)