skip_list

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLevel = 10
	SkipListP    = 0.5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem[K, V any] struct {
	// contains filtered or unexported fields
}

type Node

type Node[K, V any] struct {
	// contains filtered or unexported fields
}

Node 跳表节点

type OpFunc

type OpFunc[K, V any] func(list *SkipList[K, V])

func WithMaxLevel

func WithMaxLevel[K, V any](maxLevel int) OpFunc[K, V]

func WithRWMutex

func WithRWMutex[K, V any]() OpFunc[K, V]

WithRWMutex 赋值函数

type SkipList

type SkipList[K, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K, V any](cmp compare.CmpFunc[K], ops ...OpFunc[K, V]) *SkipList[K, V]

func (*SkipList[K, V]) Find

func (sl *SkipList[K, V]) Find(key K) (val V, ok bool)

func (*SkipList[K, V]) Insert

func (sl *SkipList[K, V]) Insert(key K, val V)

Insert 增加节点,兼顾修改值

func (*SkipList[K, V]) Len

func (sl *SkipList[K, V]) Len() int

func (*SkipList[K, V]) Remove

func (sl *SkipList[K, V]) Remove(key K) bool

Remove 删除节点

func (*SkipList[K, V]) Traversal

func (sl *SkipList[K, V]) Traversal() []Elem[K, V]

Traversal 遍历跳表

Jump to

Keyboard shortcuts

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