|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
CoinsIterator.java Created on August 11, 2002, 5:48 PM
Iterator that can accomodate the structural modification in any way in the underlying list, without throwing ConcurrentModificationException.
When an object is added to the underlying list, what is returned by the subsequent call to next(next element of this iterator) will be the same as when there were no such addition. What is returned by the call to previous will be the same as before, except for the case where the new object was added just before the next element, in which case the newly added object will be returned. The result of the call to nextIndex and previousIndex will be incremented by one if the element was added somewhere before the next element.
When an object is removed from the underlying list, what is returned by the subsequent call to next and previous will be altered if what was removed was what would be returned if there was no such removal. In that case, next and previous return the next element and the previous element of what was removed (before its removal), respectively (if any). nextIndex and previousIndex will be decremented by one if the next element of this iterator before the call to remove lied somewhere after what was removed.
ListIterator| Method Summary | |
void |
add(java.lang.Object o)
Returns what was returned by the previous call to next or previous
This is what will be removed by remove. |
void |
addAfter(java.lang.Object o)
Adds an element to the underlying list after the imaginary cursor of this iterator. |
java.lang.Object |
next()
Returns the next element, and advances the imaginary cursor by one. |
int |
nextIndex()
Returns the index of the next element |
java.lang.Object |
previous()
Returns the previous element, and steps back the imaginary cursor by one. |
int |
previousIndex()
Returns the index of the previous element |
void |
remove()
Remove what was returned by the previous call to next or previous |
| Methods inherited from interface java.util.ListIterator |
hasNext, hasPrevious, set |
| Method Detail |
public java.lang.Object next()
next in interface java.util.ListIteratorpublic java.lang.Object previous()
previous in interface java.util.ListIteratorpublic int nextIndex()
nextIndex in interface java.util.ListIteratorpublic int previousIndex()
previousIndex in interface java.util.ListIteratorpublic void remove()
next or previous
remove in interface java.util.ListIteratorjava.lang.IllegalStateException - if either there was no call to either next or previous, what was returned by such a call is already removed from the underlying list, or this iterator's method that structurally modifies the underlying list was called after such a call to next or previous.public void add(java.lang.Object o)
next or previous
This is what will be removed by remove. In the situation where remove will throw IllegalArgumentException, this method will return null.
Object lastReturned();
/**
Adds an element to the underlying list before the imaginary cursor of this iterator. That is, the subsequent call to next will be unaffected while the call to previous will return the object added by this method.
add in interface java.util.ListIteratorpublic void addAfter(java.lang.Object o)
previous will be unaffected while the call to next will return the object added by this method.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||