rbtree

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node interface {
	Parent() Node
	SetParent(Node)
	Left() Node
	SetLeft(Node)
	Right() Node
	SetRight(Node)
	IsRed() bool
	SetRed(bool)
	IsNil() bool
}

func Rebalance

func Rebalance(node Node) Node

This function rebalances and recolours trees to be valid RB trees. It needs to be called after each node that was added to the tree.

Deletions are currently not supported as this is done through the tombstone flag and from the POV of the RB-tree tombstone-nodes are just normal nodes that get rebalanced the normal way.

Throughout ths file the following relationships between nodes are used: GP = grandparent, P = parent, U = uncle, S = sibling, N = node that was just added

   GP
 /   \
U     P
     / \
    S   N

Jump to

Keyboard shortcuts

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