skiplist

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator 跳跃表迭代器

func (*Iterator) First

func (sli *Iterator) First() *SkipValue

First 获取第一个节点Value值

func (*Iterator) Last

func (sli *Iterator) Last() *SkipValue

Last 获取最后一个节点Value值

func (*Iterator) Seek

func (sli *Iterator) Seek(value *SkipValue) *SkipValue

Seek 迭代器在跳跃表中查找某个位置在传参后面或者与传参相等的SkipValue

type SkipList

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

SkipList 跳跃表

func NewSkipList

func NewSkipList(min *SkipValue) *SkipList

NewSkipList 构建一个跳跃表

func (*SkipList) Delete

func (sl *SkipList) Delete(value *SkipValue) int

Delete 删除节点

func (*SkipList) Find

func (sl *SkipList) Find(value *SkipValue) *SkipValue

Find 查找某个跳跃表中的SkipValue

func (*SkipList) FindCount

func (sl *SkipList) FindCount() int

FindCount 返回查询次数

func (*SkipList) FindGreaterOrEqual

func (sl *SkipList) FindGreaterOrEqual(value *SkipValue) *SkipValue

FindGreaterOrEqual 在跳跃表中查找某个位置在传参后面或者与传参相等的SkipValue

func (*SkipList) GetIterator

func (sl *SkipList) GetIterator() *Iterator

GetIterator 获取迭代器

func (*SkipList) Insert

func (sl *SkipList) Insert(value *SkipValue) int

Insert 插入节点

func (*SkipList) Len

func (sl *SkipList) Len() int

Len 返回节点数

func (*SkipList) Level

func (sl *SkipList) Level() int

Level 返回跳跃表的层级

func (*SkipList) Print

func (sl *SkipList) Print()

Print 测试用的输出函数

func (*SkipList) Walk

func (sl *SkipList) Walk(cb func(value interface{}) bool)

Walk 遍历整个结构,如果cb 返回false 那么停止遍历

type SkipValue

type SkipValue struct {
	Score int64
	Value interface{}
}

SkipValue 跳跃表节点的Value值

func (*SkipValue) Compare

func (v *SkipValue) Compare(value *SkipValue) int

Compare 比较函数,这样的比较排序是从大到小

Jump to

Keyboard shortcuts

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