insert key and value

This commit is contained in:
Chris Lu
2021-10-03 01:07:35 -07:00
parent 69b84bb771
commit 4f50f8c2ca
5 changed files with 84 additions and 123 deletions

View File

@@ -3,16 +3,10 @@ package skiplist
import "bytes"
func compareElement(a *SkipListElement, key []byte) int {
if len(a.Values) == 0 {
if len(a.Key) == 0 {
return -1
}
if bytes.Compare(a.Values[0], key) < 0 {
return -1
}
if bytes.Compare(a.Values[len(a.Values)-1], key) > 0 {
return 1
}
return 0
return bytes.Compare(a.Key, key)
}
var (
@@ -25,7 +19,7 @@ func (node *SkipListElement) Reference() *SkipListElementReference {
}
return &SkipListElementReference{
ElementPointer: node.Id,
Key: node.Values[0],
Key: node.Key,
}
}
func (node *SkipListElement) Save() {