Documentation
¶
Overview ¶
Example ¶
skl := NewSkipList() val := []byte("test_val") skl.Put([]byte("ec"), val) skl.Put([]byte("dc"), val) skl.Put([]byte("ac"), val) skl.Put([]byte("ae"), val) skl.Put([]byte("fe"), val) ok := skl.Exist([]byte("ac")) fmt.Println(ok) skl.Remove([]byte("ec")) ele := skl.Get([]byte("dc")) fmt.Printf("%+v", ele) pre := skl.FindPrefix([]byte("a")) fmt.Printf("%+v", pre)
Output:
Index ¶
- type Element
- type Indexer
- type Node
- type SkipList
- func (t *SkipList) Exist(key []byte) bool
- func (t *SkipList) FindPrefix(prefix []byte) *Element
- func (t *SkipList) Foreach(fun handleEle)
- func (t *SkipList) Front() *Element
- func (t *SkipList) Get(key []byte) *Element
- func (t *SkipList) Put(key []byte, value interface{}) *Element
- func (t *SkipList) Remove(key []byte) *Element
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { Node // contains filtered or unexported fields }
Element element is the data stored.
func (*Element) Next ¶
Next the first-level index of the skip list is the original data, which is arranged in an orderly manner. A linked list of all data in series can be obtained according to the Next method.
type Indexer ¶
type Indexer struct { Meta *storage.Meta // metadata info. FileId uint32 // the file id of storing the data. Offset int64 // entry data query start position. }
Indexer the data index info, stored in skip list.
type SkipList ¶
SkipList define the skip list.
func (*SkipList) FindPrefix ¶
FindPrefix find the first element that matches the prefix.
func (*SkipList) Foreach ¶
func (t *SkipList) Foreach(fun handleEle)
Foreach iterate all elements in the skip list.
func (*SkipList) Front ¶
Front first element. Get the head element of skl, and get all data by traversing backward.
e := list.Front() for p := e; p != nil; p = p.Next() { //do something with Element p }
Click to show internal directories.
Click to hide internal directories.