tree

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

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