K - type of keys, must be comparableV - type of valuespublic class SkipLevels<K extends Comparable<? super K>,V> extends Object implements Flushable
| Modifier and Type | Field and Description |
|---|---|
SkipSpan<K,V> | bottomBottom level pointer to the actual SkipSpan |
SkipLevels<K,V>[] | levelsArray of level pointers at each height |
static int | MAX_SIZEMaximum number of levels in a skip list |
| Modifier | Constructor and Description |
|---|---|
protected | SkipLevels()Protected constructor for subclasses. |
| SkipLevels(int size,
SkipSpan<K,V> span)Create a new SkipLevels with the specified size. |
| Modifier and Type | Method and Description |
|---|---|
boolean | blvlck(boolean fix)Run an integrity check on this level. |
boolean | blvlck(boolean fix,
int width,
SkipLevels<K,V>[] prevLevels)Run an integrity check on this level with additional parameters. |
void | flush()Flush this level to disk. |
V | get(int start,
K key)Get the value associated with the given key. |
SkipSpan<K,V> | getEnd()Get the end span of this level. |
SkipSpan<K,V> | getSpan(int start,
K key,
int[] search)Get the span containing or following the given key. |
K | key()Get the key at the bottom of this level. |
void | killInstance()Mark this instance as killed. |
SkipLevels<K,V> | newInstance(int levels,
SkipSpan<K,V> ss,
SkipList<K,V> sl)Create a new instance of this SkipLevels. |
String | print()Print this level and all levels below it. |
String | printAll()Print this level and all levels below it, recursively. |
SkipLevels<K,V> | put(int start,
K key,
V val,
SkipList<K,V> sl)Put a key-value pair into the skip list. |
Object[] | remove(int start,
K key,
SkipList<K,V> sl)Remove a key-value pair from the skip list. |
public SkipSpan<K extends Comparable<? super K>,V> bottom
public SkipLevels<K extends Comparable<? super K>,V>[] levels
public static final int MAX_SIZE
protected SkipLevels()
public SkipLevels(int size,
SkipSpan<K,V> span)size - the number of levelsspan - the bottom SkipSpanIllegalArgumentException - if size too big or too smallpublic boolean blvlck(boolean fix)
fix - if true, attempt to fix corruptionpublic boolean blvlck(boolean fix,
int width,
SkipLevels<K,V>[] prevLevels)fix - if true, attempt to fix corruptionwidth - the current widthprevLevels - previous levels to checkpublic V get(int start, K key)
start - the starting levelkey - the keypublic SkipSpan<K,V> getEnd()
public SkipSpan<K,V> getSpan(int start, K key, int[] search)
start - the starting levelkey - the keysearch - search parameters and resultspublic K key()
public void killInstance()
public SkipLevels<K,V> newInstance(int levels, SkipSpan<K,V> ss, SkipList<K,V> sl)
levels - the number of levels to createss - the SkipSpan to usesl - the SkipListpublic String print()
public String printAll()
public SkipLevels<K,V> put(int start, K key, V val, SkipList<K,V> sl)
start - the starting levelkey - the keyval - the valuesl - the SkipListpublic Object[] remove(int start, K key, SkipList<K,V> sl)
start - the starting levelkey - the keysl - the SkipList