|
|
@ -1,5 +1,7 @@ |
|
|
|
package skiplist |
|
|
|
|
|
|
|
// adapted from https://github.com/MauriceGit/skiplist/blob/master/skiplist.go
|
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"fmt" |
|
|
@ -402,6 +404,17 @@ func (t *SkipList) Prev(e *SkipListElement) *SkipListElement { |
|
|
|
return e.Prev.Load() |
|
|
|
} |
|
|
|
|
|
|
|
// ChangeValue can be used to change the actual value of a node in the skiplist
|
|
|
|
// without the need of Deleting and reinserting the node again.
|
|
|
|
// Be advised, that ChangeValue only works, if the actual key from ExtractKey() will stay the same!
|
|
|
|
// ok is an indicator, wether the value is actually changed.
|
|
|
|
func (t *SkipList) ChangeValue(e *SkipListElement, newValue []byte) (ok bool) { |
|
|
|
// The key needs to stay correct, so this is very important!
|
|
|
|
e.Value = newValue |
|
|
|
e.Save() |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
// String returns a string format of the skiplist. Useful to get a graphical overview and/or debugging.
|
|
|
|
func (t *SkipList) println() { |
|
|
|
|
|
|
|