Interface ListIterator<E>
- All Superinterfaces:
Iterator<E>
- All Known Implementing Classes:
Form.TabIterator
-
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified object into the list betweennextandprevious.booleanhasNext()Returns whether there are more elements to iterate.booleanReturns whether there are previous elements to iterate.next()Returns the next object in the iteration.intReturns the index of the next object in the iteration.previous()Returns the previous object in the iteration.intReturns the index of the previous object in the iteration.voidremove()Removes the last object returned bynextorpreviousfrom the list.voidReplaces the last object returned bynextorpreviouswith the specified object.
-
Method Details
-
add
Inserts the specified object into the list between
nextandprevious. The object inserted will be the previous object.Parameters
object: the object to insert.
Throws
-
UnsupportedOperationException: if adding is not supported by the list being iterated. -
ClassCastException: if the class of the object is inappropriate for the list. -
IllegalArgumentException: if the object cannot be added to the list.
-
hasNext
-
hasPrevious
boolean hasPrevious()Returns whether there are previous elements to iterate.
Returns
- Returns:
trueif there are previous elements,falseotherwise.See also
- #previous
-
next
-
nextIndex
int nextIndex()Returns the index of the next object in the iteration.
Returns
- Returns:
the index of the next object, or the size of the list if the iterator is at the end.
Throws
NoSuchElementException: if there are no more elements.
See also
- #next
-
previous
E previous()Returns the previous object in the iteration.
Returns
the previous object.
Throws
NoSuchElementException: if there are no previous elements.
See also
- #hasPrevious
-
previousIndex
int previousIndex()Returns the index of the previous object in the iteration.
Returns
- Returns:
the index of the previous object, or -1 if the iterator is at the beginning.
Throws
NoSuchElementException: if there are no previous elements.
See also
- #previous
-
remove
void remove()Removes the last object returned by
nextorpreviousfrom the list.Throws
-
UnsupportedOperationException: if removing is not supported by the list being iterated. -
IllegalStateException: @throws IllegalStateException ifnextorprevioushave not been called, orremoveoraddhave already been called after the last call tonextorprevious.
-
-
set
Replaces the last object returned by
nextorpreviouswith the specified object.Parameters
object: the object to set.
Throws
-
UnsupportedOperationException: if setting is not supported by the list being iterated -
ClassCastException: if the class of the object is inappropriate for the list. -
IllegalArgumentException: if the object cannot be added to the list. -
IllegalStateException: @throws IllegalStateException ifnextorprevioushave not been called, orremoveoraddhave already been called after the last call tonextorprevious.
-