btree

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 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 Btree

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

btree头结点

func New

func New[K constraints.Ordered, V any](degree int) *Btree[K, V]

func (*Btree[K, V]) Delete

func (b *Btree[K, V]) Delete(k K)

删除接口

func (*Btree[K, V]) DeleteWithPrev

func (b *Btree[K, V]) DeleteWithPrev(k K) (prev V, deleted bool)

删除接口, 返回旧值

func (*Btree[K, V]) Draw

func (b *Btree[K, V]) Draw()

func (*Btree[K, V]) Get

func (b *Btree[K, V]) Get(k K) (v V)

获取值, 忽略找不到的情况

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

func (b *Btree[K, V]) GetWithBool(k K) (v V, ok bool)

找到ok为true 找不到ok为false

func (*Btree[K, V]) Len

func (b *Btree[K, V]) Len() int

返回btree中元素的个数

func (*Btree[K, V]) Range

func (b *Btree[K, V]) Range(callback func(k K, v V) bool)

遍历b tree

func (*Btree[K, V]) RangePrev

func (b *Btree[K, V]) RangePrev(callback func(k K, v V) bool) *Btree[K, V]

从后向前倒序遍历b tree

func (*Btree[K, V]) Set

func (b *Btree[K, V]) Set(k K, v V)

设置接口, 如果有这个值, 有值就替换, 没有就新加

func (*Btree[K, V]) SetWithPrev

func (b *Btree[K, V]) SetWithPrev(k K, v V) (prev V, replaced bool)

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

func (*Btree[K, V]) TopMax

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

返回最大的n个值, 降序返回, 10, 9, 8, 7

func (*Btree[K, V]) TopMin

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

返回最小的n个值, 升序返回, 比如0,1,2,3

Jump to

Keyboard shortcuts

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