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().
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SkipIterator()
SkipIterator(SkipSpan<K,V> ss, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(V o)
boolean
hasNext()
boolean
hasPrevious()
V
next()
int
nextIndex()
K
nextKey()
The key.V
previous()
int
previousIndex()
void
remove()
void
set(V o)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
ss
protected SkipSpan<K extends Comparable<? super K>,V> ss
-
index
protected int index
-
-
Method Detail
-
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
public V 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
public K 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
public V previous()
- Specified by:
previous
in interfaceListIterator<K extends Comparable<? super K>>
- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException
-
add
public void add(V o)
- 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
public void set(V o)
- 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>>
-
-