@GwtCompatible public abstract class ForwardingListIterator<E> extends ForwardingIterator<E> implements ListIterator<E>
default
method warning: This class forwards calls to only some default
methods. Specifically, it forwards calls only for methods that existed before default
methods were introduced. For newer methods, like forEachRemaining
, it
inherits their default implementations. When those implementations invoke methods, they invoke
methods on the ForwardingListIterator
.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingListIterator()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Inserts the specified element into the list (optional operation).
|
protected abstract ListIterator<E> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
boolean |
hasPrevious()
Returns
true if this list iterator has more elements when
traversing the list in the reverse direction. |
int |
nextIndex()
Returns the index of the element that would be returned by a
subsequent call to
ListIterator.next() . |
E |
previous()
Returns the previous element in the list and moves the cursor
position backwards.
|
int |
previousIndex()
Returns the index of the element that would be returned by a
subsequent call to
ListIterator.previous() . |
void |
set(E element)
Replaces the last element returned by
ListIterator.next() or
ListIterator.previous() with the specified element (optional operation). |
hasNext, next, remove
toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
hasNext, next, remove
forEachRemaining
protected ForwardingListIterator()
protected abstract ListIterator<E> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the
instance being decorated.delegate
in class ForwardingIterator<E>
public void add(E element)
java.util.ListIterator
ListIterator.next()
, if any, and after the element
that would be returned by ListIterator.previous()
, if any. (If the
list contains no elements, the new element becomes the sole element
on the list.) The new element is inserted before the implicit
cursor: a subsequent call to next
would be unaffected, and a
subsequent call to previous
would return the new element.
(This call increases by one the value that would be returned by a
call to nextIndex
or previousIndex
.)add
in interface ListIterator<E>
element
- the element to insertpublic boolean hasPrevious()
java.util.ListIterator
true
if this list iterator has more elements when
traversing the list in the reverse direction. (In other words,
returns true
if ListIterator.previous()
would return an element
rather than throwing an exception.)hasPrevious
in interface ListIterator<E>
true
if the list iterator has more elements when
traversing the list in the reverse directionpublic int nextIndex()
java.util.ListIterator
ListIterator.next()
. (Returns list size if the list
iterator is at the end of the list.)nextIndex
in interface ListIterator<E>
next
, or list size if the list
iterator is at the end of the list@CanIgnoreReturnValue public E previous()
java.util.ListIterator
ListIterator.next()
to go back and forth. (Note that alternating calls
to next
and previous
will return the same
element repeatedly.)previous
in interface ListIterator<E>
public int previousIndex()
java.util.ListIterator
ListIterator.previous()
. (Returns -1 if the list
iterator is at the beginning of the list.)previousIndex
in interface ListIterator<E>
previous
, or -1 if the list
iterator is at the beginning of the listpublic void set(E element)
java.util.ListIterator
ListIterator.next()
or
ListIterator.previous()
with the specified element (optional operation).
This call can be made only if neither ListIterator.remove()
nor ListIterator.add(E)
have been called after the last call to next
or
previous
.set
in interface ListIterator<E>
element
- the element with which to replace the last element returned by
next
or previous
Copyright © 2010–2018. All rights reserved.