rbtree

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: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RED   color = 1
	BLACK color = 2
)

Variables

View Source
var ErrNotFound = errors.New("rbtree: not found value")

Functions

This section is empty.

Types

type RBTree

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

红黑树

func New

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

初始化函数

func (*RBTree[K, V]) Delete

func (r *RBTree[K, V]) Delete(k K)

func (*RBTree[K, V]) First

func (r *RBTree[K, V]) First() (v V, ok bool)

第一个节点

func (*RBTree[K, V]) Get

func (r *RBTree[K, V]) Get(k K) (v V)

Get

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

func (r *RBTree[K, V]) GetWithBool(k K) (v V, ok bool)

从rbtree 找到需要的值

func (*RBTree[K, V]) Last

func (r *RBTree[K, V]) Last() (v V, ok bool)

最后一个节点

func (*RBTree[K, V]) Len

func (r *RBTree[K, V]) Len() int

func (*RBTree[K, V]) Range

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

遍历rbtree

func (*RBTree[K, V]) RangePrev

func (r *RBTree[K, V]) RangePrev(callback func(k K, v V) bool)

遍历rbtree

func (*RBTree[K, V]) Set

func (r *RBTree[K, V]) Set(k K, v V)

func (*RBTree[K, V]) SetWithPrev

func (r *RBTree[K, V]) SetWithPrev(k K, v V) (prev V, replaced bool)

设置

func (*RBTree[K, V]) TopMax

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

func (*RBTree[K, V]) TopMin

func (r *RBTree[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