net.metanotion.util.skiplist
Class SkipIterator
java.lang.Object
net.metanotion.util.skiplist.SkipIterator
- All Implemented Interfaces:
- Iterator, ListIterator
- Direct Known Subclasses:
- IBSkipIterator
public class SkipIterator
- extends Object
- implements ListIterator
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().
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ss
protected SkipSpan ss
index
protected int index
SkipIterator
protected SkipIterator()
SkipIterator
public SkipIterator(SkipSpan ss,
int index)
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface Iterator
- Specified by:
hasNext
in interface ListIterator
next
public Object next()
- Specified by:
next
in interface Iterator
- Specified by:
next
in interface ListIterator
- Returns:
- the next value, and advances the index
- Throws:
NoSuchElementException
nextKey
public Comparable 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 interface ListIterator
previous
public Object previous()
- Specified by:
previous
in interface ListIterator
- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException
add
public void add(Object o)
- Specified by:
add
in interface ListIterator
remove
public void remove()
- Specified by:
remove
in interface Iterator
- Specified by:
remove
in interface ListIterator
set
public void set(Object o)
- Specified by:
set
in interface ListIterator
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interface ListIterator
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interface ListIterator