public abstract static class ObjectIterators.AbstractIndexBasedListIterator<K> extends ObjectIterators.AbstractIndexBasedIterator<K> implements ObjectListIterator<K>
This class is only appropriate for sequences that are at most Integer.MAX_VALUE
long.
If your backing data store can be bigger then this, consider the equivalently named class in
the type specific BigListSpliterators
class.
As the abstract methods in this class are used in inner loops, it is generally a
good idea to override the class as final
as to encourage the JVM to inline
them (or alternatively, override the abstract methods as final).
Modifier and Type | Method and Description |
---|---|
void |
add(K k)
Inserts the specified element into the list (optional operation).
|
int |
back(int n)
Moves back for the given number of elements.
|
boolean |
hasPrevious()
Returns whether there is a previous element.
|
int |
nextIndex() |
K |
previous()
Returns the previous element from the collection.
|
int |
previousIndex() |
void |
set(K k)
Replaces the last element returned by
Iterator.next() or
BidirectionalIterator.previous() with the specified element (optional operation). |
forEachRemaining, hasNext, next, remove, skip
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
remove
skip
public boolean hasPrevious()
BidirectionalIterator
hasPrevious
in interface BidirectionalIterator<K>
hasPrevious
in interface java.util.ListIterator<K>
ListIterator.hasPrevious()
public K previous()
BidirectionalIterator
previous
in interface BidirectionalIterator<K>
previous
in interface java.util.ListIterator<K>
ListIterator.previous()
public int nextIndex()
nextIndex
in interface java.util.ListIterator<K>
public int previousIndex()
previousIndex
in interface java.util.ListIterator<K>
public void add(K k)
ObjectListIterator
This default implementation just throws an UnsupportedOperationException
.
add
in interface ObjectListIterator<K>
add
in interface java.util.ListIterator<K>
k
- the element to insert.ListIterator.add(Object)
public void set(K k)
ObjectListIterator
Iterator.next()
or
BidirectionalIterator.previous()
with the specified element (optional operation).set
in interface ObjectListIterator<K>
set
in interface java.util.ListIterator<K>
k
- the element used to replace the last element returned.
This default implementation just throws an UnsupportedOperationException
.
ListIterator.set(Object)
public int back(int n)
ObjectBidirectionalIterator
The effect of this call is exactly the same as that of
calling BidirectionalIterator.previous()
for n
times (possibly stopping
if BidirectionalIterator.hasPrevious()
becomes false).
back
in interface ObjectBidirectionalIterator<K>
n
- the number of elements to skip back.BidirectionalIterator.previous()