K - type of keys, must be comparableV - type of valuespublic class SkipList<K extends Comparable<? super K>,V> extends Object implements Flushable, Iterable<V>
| Modifier and Type | Field and Description |
|---|---|
protected SkipSpan<K,V> | firstFirst span in the list. |
protected static int | PThe probability of each next higher level. |
static Random | rngRandom number generator. |
protected int | sizeNumber of items in the list. |
protected SkipLevels<K,V> | stackLevel stack above the first span. |
| Modifier | Constructor and Description |
|---|---|
protected | SkipList()Constructor for subclass use. |
| SkipList(int span)Create a new skip list. |
| Modifier and Type | Method and Description |
|---|---|
void | addItem()Increment item count. |
void | balance()Rebalance the skip list levels. |
void | delItem()Decrement item count, minimum zero. |
SkipIterator<K,V> | find(K key) |
void | flush()Flush any pending writes. |
int | generateColHeight() |
V | get(K key)Get the value for a key. |
SkipIterator<K,V> | iterator()Return an iterator over all entries. |
int | maxLevels() |
void | put(K key,
V val)Insert or update a key-value pair in the skip list. |
V | remove(K key)Remove a key-value pair from the skip list. |
int | size()Return the number of items. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected SkipSpan<K extends Comparable<? super K>,V> first
protected static final int P
public static final Random rng
protected int size
protected SkipLevels<K extends Comparable<? super K>,V> stack
protected SkipList()
public SkipList(int span)
span - span sizeIllegalArgumentException - if size too big or too smallpublic void addItem()
public void balance()
public void delItem()
public SkipIterator<K,V> find(K key)
public int generateColHeight()
public V get(K key)
key - the keypublic SkipIterator<K,V> iterator()
public int maxLevels()
public void put(K key, V val)
key - the keyval - the valuepublic V remove(K key)
key - the keypublic int size()