rbtree

package
v0.0.0-...-c500841 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixFunc

type FixFunc[T cmp.Ordered] func(*rbNode[T]) *rbNode[T]

FixFunc 修复红黑树的函数定义

type RBTree

type RBTree[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

RBTree 红黑树

func NewRBTree

func NewRBTree[T cmp.Ordered]() *RBTree[T]

NewRBTree 创建红黑树

func (*RBTree[T]) Delete

func (rb *RBTree[T]) Delete(val T) error

Delete 删除

func (*RBTree[T]) Find

func (rb *RBTree[T]) Find(val T) *rbNode[T]

Find 查找

func (*RBTree[T]) Insert

func (rb *RBTree[T]) Insert(val T) error

Insert 插入

func (*RBTree[T]) IsValid

func (rb *RBTree[T]) IsValid() bool

IsValid 验证红黑树所有性质:

1. 根节点为黑色 2. 红色节点不能连续出现 3. 所有路径黑高一致 4. 叶子节点(NIL)视为黑色

Jump to

Keyboard shortcuts

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