skiplist

package module
v0.0.0-...-a233dd9 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 3 Imported by: 0

README

skiplist

skiplist implementation in go

l := skiplist.New[int, string]()

l.Insert(1, "10")
l.Insert(1, "20")
l.Insert(1, "30")

v, ok := l.Get(3) // "30", true

l.Insert(3, "90") // updates
v, ok = l.Get(3) // "90", true

ok = l.Delete(3) // true

length := l.Length() // 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SkipList

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

func New

func New[K constraints.Ordered, V any](maxLevel ...int) *SkipList[K, V]

func (*SkipList[K, V]) Delete

func (l *SkipList[K, V]) Delete(key K) bool

func (*SkipList[K, V]) Get

func (l *SkipList[K, V]) Get(key K) (V, bool)

func (*SkipList[K, V]) Insert

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

func (*SkipList[K, V]) Length

func (l *SkipList[K, V]) Length() int

Jump to

Keyboard shortcuts

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