MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / NewRB

Function NewRB

structure/tree/rbtree.go:57–64  ·  view source on GitHub ↗

NewRB creates a new Red-Black Tree

()

Source from the content-addressed store, hash-verified

55
56// NewRB creates a new Red-Black Tree
57func NewRB[T constraints.Ordered]() *RB[T] {
58 leaf := &RBNode[T]{color: Black, left: nil, right: nil}
59 leaf.parent = leaf
60 return &RB[T]{
61 Root: leaf,
62 _NIL: leaf,
63 }
64}
65
66// Empty determines the Red-Black tree is empty
67func (t *RB[T]) Empty() bool {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected