Package net.metanotion.util.skiplist
Class SkipIterator<K extends Comparable<? super K>,V>
java.lang.Object
net.metanotion.util.skiplist.SkipIterator<K,V>
- 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, the nextIndex and previousIndex methods are not really relevant.
To be clear, this is an iterator through the values.
To get the key, call nextKey() BEFORE calling next().
-
Field Details
-
ss
-
index
protected int index
-
-
Constructor Details
-
SkipIterator
protected SkipIterator() -
SkipIterator
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<K extends Comparable<? super K>>- Specified by:
hasNextin interfaceListIterator<K extends Comparable<? super K>>
-
next
- 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
-
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
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPreviousin interfaceListIterator<K extends Comparable<? super K>>
-
previous
- Specified by:
previousin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException
-
add
- Specified by:
addin interfaceListIterator<K extends Comparable<? super K>>
-
remove
public void remove()- Specified by:
removein interfaceIterator<K extends Comparable<? super K>>- Specified by:
removein interfaceListIterator<K extends Comparable<? super K>>
-
set
- Specified by:
setin interfaceListIterator<K extends Comparable<? super K>>
-
nextIndex
public int nextIndex()- Specified by:
nextIndexin interfaceListIterator<K extends Comparable<? super K>>
-
previousIndex
public int previousIndex()- Specified by:
previousIndexin interfaceListIterator<K extends Comparable<? super K>>
-