BRUtil - Making Java a Kinder, Gentler, Place to be.

brutil
Interface ListIterator

All Superinterfaces:
java.util.Iterator

public interface ListIterator
extends java.util.Iterator

A uni-directional iterator that moves in the forward direction. The ForwardListIterator contains a cursor that lies between elements and that begins before the first element. Calls to next return the element after the implicit cursor. Current item is defined as the most recent element returned by next. If none has been returned or the current item has become undefined, then methods that require a current item will fail. The methods remove and set require a current item. The methods remove and insert make the current item undefined. The ListIterator does not support commodification, so any structural modification of the list during the ListIterator's lifetime will result in arbitrary behavior from all ListIterator Methods.


Method Summary
 java.lang.Object currentElement()
          Returns the current element this Iterator points to, which is the value returned by the last call to next().
 boolean hasNext()
          Returns true if an element exists after the cursor.
 void insert(java.lang.Object elt)
          The given element is inserted immediately before the cursor.
 java.lang.Object next()
          Returns the element after the cursor and advances the cursor forwards.
 void remove()
          Removes the current item from the list.
 java.lang.Object set(java.lang.Object elt)
          Replaces the current item.
 

Method Detail

hasNext

public boolean hasNext()
Returns true if an element exists after the cursor. next will return the element.
Specified by:
hasNext in interface java.util.Iterator
Returns:
true if an element exists after the cursor.

next

public java.lang.Object next()
Returns the element after the cursor and advances the cursor forwards. Current item becomes the element returned.
Specified by:
next in interface java.util.Iterator
Returns:
The element after the cursor.
Throws:
NoSuchElementException - if the cursor is after the last element.

currentElement

public java.lang.Object currentElement()
Returns the current element this Iterator points to, which is the value returned by the last call to next(). Does not advance Iterator.
Returns:
The current element.
Throws:
NoSuchElementException - if the cursor is after the last element.

remove

public void remove()
Removes the current item from the list. This method will fail if the current item is undefined. Current item becomes undefined.
Specified by:
remove in interface java.util.Iterator
Throws:
IllegalStateException - if current item is undefined.

set

public java.lang.Object set(java.lang.Object elt)
Replaces the current item. This method will fail if the current item is undefined.
Parameters:
elt - the element to replace the current item's element.
Throws:
IllegalStateException - if current item is undefined.

insert

public void insert(java.lang.Object elt)
The given element is inserted immediately before the cursor. A subsequent call to next is unaffected. If the list is empty, the new element becomes the sole element in the list. Current item becomes undefined.
Parameters:
elt - the element to be inserted.


BRUtil - Making Java a Kinder, Gentler, Place to be.