skiplist

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 3 Imported by: 1

README

skiplist

implement skiplist

Example

go get github.com/ISSuh/skiplist

import github.com/ISSuh/skiplist


list := skipList.New(5)
list.Set("key", "value")

item := list.Get("key")
fmt.Printf("key : %s / value : %s", item.key, item.value)

Test Case

$ go test -bench . -benchtime 5000000x
goos: darwin
goarch: arm64
pkg: github.com/ISSuh/skiplist
BenchmarkSet-8           5000000              1587 ns/op        3150955.24 MB/s      144 B/op          4 allocs/op
BenchmarkGet-8           5000000              1834 ns/op        2725794.73 MB/s        7 B/op          0 allocs/op
PASS
ok      github.com/ISSuh/skiplist       18.181s
$ go test -cover                
PASS
        github.com/ISSuh/skiplist       coverage: 100.0% of statements
ok      github.com/ISSuh/skiplist       0.337s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SkipList

type SkipList struct {
	// contains filtered or unexported fields
}

func New

func New(maxLevel int) *SkipList

func (*SkipList) Back

func (list *SkipList) Back() *SkipListNode

func (*SkipList) Front

func (list *SkipList) Front() *SkipListNode

func (*SkipList) Get

func (list *SkipList) Get(key string) *SkipListItem

func (*SkipList) Length

func (list *SkipList) Length() int

func (*SkipList) MaxLevel

func (list *SkipList) MaxLevel() int

func (*SkipList) Remove

func (list *SkipList) Remove(key string)

func (*SkipList) Set

func (list *SkipList) Set(key string, value []byte)

func (*SkipList) Size added in v0.0.2

func (list *SkipList) Size() uint64

type SkipListItem

type SkipListItem struct {
	// contains filtered or unexported fields
}

func (*SkipListItem) Key

func (item *SkipListItem) Key() string

func (*SkipListItem) Value

func (item *SkipListItem) Value() []byte

type SkipListNode

type SkipListNode struct {
	// contains filtered or unexported fields
}

func (*SkipListNode) Key

func (node *SkipListNode) Key() string

func (*SkipListNode) Next

func (node *SkipListNode) Next() *SkipListNode

func (*SkipListNode) Prev

func (node *SkipListNode) Prev() *SkipListNode

func (*SkipListNode) Value

func (node *SkipListNode) Value() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL