redgreen

package
v0.0.0-...-fab4c1e Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redgreen contains a generic implementation of a red-green binary search tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SearchTree

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

SearchTree is a red-green binary search tree, based on CLRS 4th edition. Not thread-safe.

func New

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

New returns is a self-balancing red-green binary search tree. Not thread-safe.

func NewT

func NewT[K, V any](cmp lang.CompareFn[K]) *SearchTree[K, V]

NewT returns is a self-balancing red-green binary search tree. Not thread-safe.

func (*SearchTree[K, V]) Find

func (t *SearchTree[K, V]) Find(key K) (V, bool)

func (*SearchTree[K, V]) Height

func (t *SearchTree[K, V]) Height() int

Height returns the height of the tree, i.e., the number of nodes on the longest path.

func (*SearchTree[K, V]) Insert

func (t *SearchTree[K, V]) Insert(key K, value V) (V, bool)

func (*SearchTree[K, V]) IsEmpty

func (t *SearchTree[K, V]) IsEmpty() bool

func (*SearchTree[K, V]) List

func (t *SearchTree[K, V]) List() lang.Iterator[container.KV[K, V]]

func (*SearchTree[K, V]) Remove

func (t *SearchTree[K, V]) Remove(key K) (V, bool)

func (*SearchTree[K, V]) String

func (t *SearchTree[K, V]) String() string

Jump to

Keyboard shortcuts

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