Class org.as2lib.data.holder.list.ListIterator

org.as2lib.core.BasicClass
   +--org.as2lib.data.holder.list.ListIterator

Implemented Interfaces

Iterator

Description

ListIterator iterates over lists, that are instances of classes that implement the 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
 

Method Index

new ListIterator()

hasNext(), next(), remove()

Inherited from BasicClass

toString()

Constructor Detail

ListIterator

public function ListIterator(target:List)

Constructs a new ListIterator instance.

Parameters

targetthe list to iterate over

Method Detail

hasNext

public function hasNext(Void):Boolean

Returns whether there is another element to iterate over.

Return

true if there is at least one element left to iterate over

Specified By

hasNext() in org.as2lib.data.holder.Iterator

next

public function next(Void)

Returns the next element.

Return

the next element

Throws

NoSuchElementExceptionif there is no next element

Specified By

next() in org.as2lib.data.holder.Iterator

remove

public function remove(Void):Void

Removes the currently selected element from this iterator and from the data holder this iterator iterates over.

Throws

IllegalStateExceptionif you try to remove an element when none is selected

Specified By

remove() in org.as2lib.data.holder.Iterator