skip_list

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

img.png

Documentation

Index

Constants

View Source
const (
	MaxLevel    = 18         //最大层数
	Probability = 1 / math.E //每一个节点是否可以向上的概率基数
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparable

type Comparable interface {
	CompareTo(Comparable) int
}

Comparable 大于返回正数,小于返回负数,等于返回0

type Element

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

type KV

type KV struct {
	K Comparable
	V interface{}
}

func NewKV

func NewKV(key Comparable, value interface{}) *KV

type SkipList

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

func NewSkipList

func NewSkipList() *SkipList

func (*SkipList) Delete

func (sList *SkipList) Delete(key Comparable)

Delete 删除数据

func (*SkipList) Get

func (sList *SkipList) Get(k Comparable) (*KV, bool)

Get 获取数据 如果没有相等的数据,返回它的下一个元素(也可能是nil),bool仍是false

func (*SkipList) GetMax

func (sList *SkipList) GetMax() (kv *KV)

GetMax 获取最后一个元素

func (*SkipList) GetMin

func (sList *SkipList) GetMin() (kv *KV)

GetMin 获取第一个元素

func (*SkipList) Len

func (sList *SkipList) Len() int

Len 获取长度

func (*SkipList) PrevNodeCache

func (sList *SkipList) PrevNodeCache(k Comparable) []*Element

PrevNodeCache 每一层下来的节点所组成的切片

func (*SkipList) Put

func (sList *SkipList) Put(kv *KV)

Put 插入数据

Jump to

Keyboard shortcuts

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