list

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

链表

type Node

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

链表结点

type SkipList

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

A SkipList maintains an ordered collection of key:valkue pairs. It support insertion, lookup, and deletion operations with O(log n) time complexity Paper: Pugh, William (June 1990). "Skip lists: a probabilistic alternative to balanced trees". Communications of the ACM 33 (6): 668–676

func NewSkipList

func NewSkipList(less def.Less) *SkipList

NewSkipList returns a skiplist.

func (*SkipList) Del

func (s *SkipList) Del(k interface{}) (v interface{}, ok bool)

Del returns the deleted value if ok

func (*SkipList) Get

func (s *SkipList) Get(k interface{}) (v interface{}, ok bool)

Get returns corresponding v with given k.

func (*SkipList) Len

func (s *SkipList) Len() int

Len returns the length of given skiplist.

func (*SkipList) Range

func (s *SkipList) Range(from, to interface{}, op func(v interface{}))

Range interates `from` to `to` with `op`.

func (*SkipList) Search

func (s *SkipList) Search(k interface{}) (ok bool)

Search returns true if k is founded in the skiplist.

func (*SkipList) Set

func (s *SkipList) Set(k interface{}, v interface{})

Set sets given k and v pair into the skiplist.

Jump to

Keyboard shortcuts

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