tree

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Red   color = false
	Black color = true
)

Variables

View Source
var (
	ErrRBTreeSameRBNode = errors.New("ekit: RBTree不能添加重复节点Key")
	ErrRBTreeNotRBNode  = errors.New("ekit: RBTree不存在节点Key")
)

Functions

This section is empty.

Types

type RBTree

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

func NewRBTree

func NewRBTree[K any, V any](compare ekit.Comparator[K]) *RBTree[K, V]

NewRBTree 构建红黑树

func (*RBTree[K, V]) Add

func (rb *RBTree[K, V]) Add(key K, value V) error

Add 增加节点

func (*RBTree[K, V]) Delete

func (rb *RBTree[K, V]) Delete(key K) (V, bool)

Delete 删除节点

func (*RBTree[K, V]) Find

func (rb *RBTree[K, V]) Find(key K) (V, error)

Find 查找节点

func (*RBTree[K, V]) KeyValues

func (rb *RBTree[K, V]) KeyValues() ([]K, []V)

KeyValues 获取红黑树所有节点K,V

func (*RBTree[K, V]) Set

func (rb *RBTree[K, V]) Set(key K, value V) error

func (*RBTree[K, V]) Size

func (rb *RBTree[K, V]) Size() int

Jump to

Keyboard shortcuts

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