avltree

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvlTree

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

avl tree的结构

func New

func New[K constraints.Ordered, V any]() *AvlTree[K, V]

构造函数

func (*AvlTree[K, V]) Delete

func (a *AvlTree[K, V]) Delete(k K)

func (*AvlTree[K, V]) Draw

func (a *AvlTree[K, V]) Draw()

func (*AvlTree[K, V]) First

func (a *AvlTree[K, V]) First() (v V, ok bool)

第一个节点

func (*AvlTree[K, V]) Get

func (a *AvlTree[K, V]) Get(k K) (v V)

Get

func (*AvlTree[K, V]) GetWithBool added in v0.0.6

func (a *AvlTree[K, V]) GetWithBool(k K) (v V, ok bool)

从avl tree找到需要的值

func (*AvlTree[K, V]) Last

func (a *AvlTree[K, V]) Last() (v V, ok bool)

最后一个节点

func (*AvlTree[K, V]) Len

func (a *AvlTree[K, V]) Len() int

func (*AvlTree[K, V]) Range

func (a *AvlTree[K, V]) Range(callback func(k K, v V) bool)

遍历avl tree

func (*AvlTree[K, V]) RangePrev

func (a *AvlTree[K, V]) RangePrev(callback func(k K, v V) bool)

遍历avl tree

func (*AvlTree[K, V]) Remove

func (a *AvlTree[K, V]) Remove(k K) *AvlTree[K, V]

func (*AvlTree[K, V]) Set

func (a *AvlTree[K, V]) Set(k K, v V)

func (*AvlTree[K, V]) SetWithPrev

func (a *AvlTree[K, V]) SetWithPrev(k K, v V) (prev V, replaced bool)

设置接口, 如果有值, 把prev值带返回, 并且被替换, 没有就新加

func (*AvlTree[K, V]) TopMax

func (a *AvlTree[K, V]) TopMax(limit int, callback func(k K, v V) bool)

func (*AvlTree[K, V]) TopMin

func (a *AvlTree[K, V]) TopMin(limit int, callback func(k K, v V) bool)

Jump to

Keyboard shortcuts

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