java.lang.Object
net.metanotion.util.skiplist.SkipIterator<K,V>
- Type Parameters:
K- type of keys maintained by this iteratorV- type of values returned by this iterator
- All Implemented Interfaces:
Iterator<V>, ListIterator<V>
- Direct Known Subclasses:
IBSkipIterator
public class SkipIterator<K extends Comparable<? super K>, V>extends Object implements ListIterator<V>
A basic iterator for a skip list. This is not a complete ListIterator, in particular, since the skip list is a map and is therefore indexed by Comparable objects instead of int's, nextIndex and previousIndex methods are not really relevant. To be clear, this is an iterator through values. To get the key, call
nextKey() BEFORE calling next().Field Summary
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for subclass use.SkipIterator(SkipSpan<K, V> ss, int index) Rejects a null span, then starts iterating at the given index.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidNot supported.booleanhasNext()Whether more values follow.booleanWhether a previous value exists.next()Next value in the iteration.intNot supported.nextKey()The key.previous()Previous value in the iteration.intNot supported.voidremove()Not supported.voidNot supported.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
Field Details
ss
The current span being iterated over.index
protected int indexCurrent index position.
Constructor Details
SkipIterator
protected SkipIterator()Constructor for subclass use.SkipIterator
Method Details
hasNext
public boolean hasNext()Whether more values follow.- Specified by:
hasNextin interfaceIterator<K extends Comparable<? super K>>- Specified by:
hasNextin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- whether next is present
next
Next value in the iteration.- Specified by:
nextin interfaceIterator<K extends Comparable<? super K>>- Specified by:
nextin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- the next value, and advances the index
- Throws:
NoSuchElementException- if the iterator is past the last value
nextKey
The key. Does NOT advance the index.- Returns:
- the key for which the value will be returned in the subsequent call to
next() - Throws:
NoSuchElementException- if the iterator is past the last key
hasPrevious
public boolean hasPrevious()Whether a previous value exists.- Specified by:
hasPreviousin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- whether previous is present
previous
Previous value in the iteration.- Specified by:
previousin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException- if the iterator is before the first value
add
Not supported.- Specified by:
addin interfaceListIterator<K extends Comparable<? super K>>
remove
public void remove()Not supported.- Specified by:
removein interfaceIterator<K extends Comparable<? super K>>- Specified by:
removein interfaceListIterator<K extends Comparable<? super K>>
set
Not supported.- Specified by:
setin interfaceListIterator<K extends Comparable<? super K>>
nextIndex
public int nextIndex()Not supported.- Specified by:
nextIndexin interfaceListIterator<K extends Comparable<? super K>>
previousIndex
public int previousIndex()Not supported.- Specified by:
previousIndexin interfaceListIterator<K extends Comparable<? super K>>