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).
lastReturned, minPos, pos| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIndexBasedListIterator(int minPos,
int initialPos) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
add(int location,
K k)
Add the given item at the given index.
|
void |
add(K k)
Inserts the specified element into the list (optional operation).
|
int |
back(int n) |
boolean |
hasPrevious() |
int |
nextIndex() |
K |
previous() |
int |
previousIndex() |
protected abstract void |
set(int location,
K k)
Sets the given item at the given index.
|
void |
set(K k)
Replaces the last element returned by
Iterator.next() or
BidirectionalIterator.previous() with the specified element (optional operation). |
forEachRemaining, get, getMaxPos, hasNext, next, remove, remove, skipclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitremoveprotected AbstractIndexBasedListIterator(int minPos,
int initialPos)
protected abstract void add(int location,
K k)
This method should also do what is needed to track the change to the ObjectIterators.AbstractIndexBasedIterator.getMaxPos().
Usually this is accomplished by having this method call the parent Collection's appropriate add
method, and having ObjectIterators.AbstractIndexBasedIterator.getMaxPos() track the parent collection's size.
Do not modify ObjectIterators.AbstractIndexBasedIterator.pos in this method; the default #add() method takes care of this.
See ObjectIterators.AbstractIndexBasedIterator.pos and ObjectIterators.AbstractIndexBasedIterator.get(int) for discussion on what the location means.
protected abstract void set(int location,
K k)
See ObjectIterators.AbstractIndexBasedIterator.pos and ObjectIterators.AbstractIndexBasedIterator.get(int) for discussion on what the location means.
public boolean hasPrevious()
public K 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)
ObjectListIteratorThis 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)
ObjectListIteratorIterator.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)
back in interface it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator<K>