Package net.metanotion.util.skiplist
Class SkipList<K extends Comparable<? super K>,V>
- java.lang.Object
-
- net.metanotion.util.skiplist.SkipList<K,V>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addItem()
void
balance()
void
delItem()
SkipIterator<K,V>
find(K key)
void
flush()
int
generateColHeight()
V
get(K key)
SkipIterator<K,V>
iterator()
int
maxLevels()
void
print()
Deprecated.goes to System.outvoid
printSL()
Deprecated.goes to System.outvoid
put(K key, V val)
V
remove(K key)
int
size()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
P
protected static final int P
the probability of each next higher level- See Also:
- Constant Field Values
-
first
protected SkipSpan<K extends Comparable<? super K>,V> first
-
stack
protected SkipLevels<K extends Comparable<? super K>,V> stack
-
rng
public static final Random rng
-
size
protected int size
-
-
Method Detail
-
size
public int size()
-
addItem
public void addItem()
-
delItem
public void delItem()
-
maxLevels
public int maxLevels()
- Returns:
- 4 since we don't track span count here any more - see override Fix if for some reason you want a huge in-memory skiplist.
-
generateColHeight
public int generateColHeight()
- Returns:
- 0..maxLevels(), each successive one with probability 1 / P
-
printSL
@Deprecated public void printSL()
Deprecated.goes to System.outdumps all the skip levels
-
print
@Deprecated public void print()
Deprecated.goes to System.outdumps all the data
-
iterator
public SkipIterator<K,V> iterator()
- Specified by:
iterator
in interfaceIterable<K extends Comparable<? super K>>
-
find
public SkipIterator<K,V> find(K key)
- Returns:
- an iterator where nextKey() is the first one greater than or equal to 'key'
-
balance
public void balance()
-
-