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:
hasNext
in interfaceIterator<K extends Comparable<? super K>>
- Specified by:
hasNext
in interfaceListIterator<K extends Comparable<? super K>>
-
next
- Specified by:
next
in interfaceIterator<K extends Comparable<? super K>>
- Specified by:
next
in 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:
hasPrevious
in interfaceListIterator<K extends Comparable<? super K>>
-
previous
- Specified by:
previous
in interfaceListIterator<K extends Comparable<? super K>>
- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException
-
add
- Specified by:
add
in interfaceListIterator<K extends Comparable<? super K>>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<K extends Comparable<? super K>>
- Specified by:
remove
in interfaceListIterator<K extends Comparable<? super K>>
-
set
- Specified by:
set
in interfaceListIterator<K extends Comparable<? super K>>
-
nextIndex
public int nextIndex()- Specified by:
nextIndex
in interfaceListIterator<K extends Comparable<? super K>>
-
previousIndex
public int previousIndex()- Specified by:
previousIndex
in interfaceListIterator<K extends Comparable<? super K>>
-