ListIterator
| Kind of class: | class |
|---|---|
| Inherits from: | BasicClass |
| Implements: | |
| Author: | Simon Wacker |
| Classpath: | org.as2lib.data.holder.list.ListIterator |
| File last modified: | Sunday, 10 July 2005, 15:41:22 |
ListIterator iterates over lists, that are instances of classes thatimplement the org.as2lib.data.holder.List interface.
An iterator is quite simple to use. There is one method to check whether there
are more elements left to iterate over hasNext, one method to get the
next element next and one to remove the current element remove.
Example:
var list:List = new MyList(); list.insert("value1"); list.insert("value2"); list.insert("value3"); var iterator:Iterator = new ListIterator(list); while (iterator.hasNext()) { trace(iterator.next()); }
Output:
value1 value2 value3
Summary
Constructor
Constructor
ListIterator
function ListIterator (
target:List)
Constructs a new
ListIterator instance.Parameters:
target:
the list to iterate over
Instance methods
hasNext
function hasNext (
Void) : Boolean
Returns whether there is another element to iterate over.
Returns:
over
true if there is at least one element left to iterateover
Specified by:
next
function next (
Void)
Returns the next element.
Returns:
the next element
Throws:
org.as2lib.data.holder.NoSuchElementException if there is no next element
Specified by:
remove
function remove (
Void) : Void
Removes the currently selected element from this iterator and from the data holder
this iterator iterates over.
this iterator iterates over.
Throws:
org.as2lib.env.except.IllegalStateException if you try to remove an element
when none is selected
when none is selected
Specified by: