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 protectedSkipIterator()SkipIterator(SkipSpan<K,V> ss, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(V o)booleanhasNext()booleanhasPrevious()Vnext()intnextIndex()KnextKey()The key.Vprevious()intpreviousIndex()voidremove()voidset(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:
hasNextin interfaceIterator<K extends Comparable<? super K>>- Specified by:
hasNextin interfaceListIterator<K extends Comparable<? super K>>
-
next
public V 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
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:
hasPreviousin interfaceListIterator<K extends Comparable<? super K>>
-
previous
public V previous()
- Specified by:
previousin interfaceListIterator<K extends Comparable<? super K>>- Returns:
- the previous value, and decrements the index
- Throws:
NoSuchElementException
-
add
public void add(V o)
- 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
public void set(V o)
- 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>>
-
-