java.lang.Object
net.metanotion.util.skiplist.SkipLevels<K,V>
- Type Parameters:
K- type of keys, must be comparableV- type of values
- All Implemented Interfaces:
Flushable
- Direct Known Subclasses:
BSkipLevels
Manages the level structure for a skip list data structure. Maintains pointers to different levels in the skip list hierarchy.
Field Summary
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor for subclasses.SkipLevels(int size, SkipSpan<K, V> span) Create a new SkipLevels with the specified size.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanblvlck(boolean fix) Run an integrity check on this level.booleanblvlck(boolean fix, int width, SkipLevels<K, V>[] prevLevels) Run an integrity check on this level with additional parameters.voidflush()Flush this level to disk.Get the value associated with the given key.getEnd()Get the end span of this level.Get the span containing or following the given key.key()Get the key at the bottom of this level.voidMark this instance as killed.SkipLevels<K, V> Create a new instance of this SkipLevels.print()Print this level and all levels below it.printAll()Print this level and all levels below it, recursively.SkipLevels<K, V> Put a key-value pair into the skip list.Object[]Remove a key-value pair from the skip list.
Field Details
MAX_SIZE
public static final int MAX_SIZEMaximum number of levels in a skip list- See Also:
levels
Array of level pointers at each heightbottom
Bottom level pointer to the actual SkipSpan_log
Logger for this instance
Constructor Details
SkipLevels
protected SkipLevels()Protected constructor for subclasses.SkipLevels
Create a new SkipLevels with the specified size.- Parameters:
size- the number of levelsspan- the bottom SkipSpan- Throws:
IllegalArgumentException- if size too big or too small
Method Details
newInstance
Create a new instance of this SkipLevels.- Parameters:
levels- the number of levels to createss- the SkipSpan to usesl- accepted for signature compatibility with the other levels, unused- Returns:
- a new SkipLevels instance
killInstance
public void killInstance()Mark this instance as killed.flush
print
Print this level and all levels below it.- Returns:
- a string representation of this level
printAll
Print this level and all levels below it, recursively.- Returns:
- a string representation of all levels
getEnd
getSpan
Get the span containing or following the given key.- Parameters:
start- the starting levelkey- the key to locate, compared with compareTo() against each level's keysearch- search parameters and results- Returns:
- the SkipSpan containing the key
key
get
remove
Remove a key-value pair from the skip list.- Parameters:
start- the starting levelkey- the key of the entry to removesl- the owning SkipList, passed down and used for the head pointer- Returns:
- An array of two objects or null. rv[0] is the removed object. rv[1] is the deleted SkipLevels if the removed object was the last in the SkipLevels, and the deleted SkipLevels is taller than this SkipLevels. rv is null if no object was removed.
put
Put a key-value pair into the skip list.- Parameters:
start- the starting levelkey- the key to map to the value, replacing any existing entryval- the valuesl- the owning SkipList, which supplies the random column height- Returns:
- the new level if it caused a split and we made a new level, and the new level is taller than our level; else null if it went in an existing level or the new level is our height or less.
blvlck
public boolean blvlck(boolean fix) Run an integrity check on this level.- Parameters:
fix- if true, attempt to fix corruption- Returns:
- true if corruption was found
blvlck
Run an integrity check on this level with additional parameters.- Parameters:
fix- if true, attempt to fix corruptionwidth- the current widthprevLevels- previous levels to check- Returns:
- true if corruption was found