Documentation ¶
Index ¶
- func BreadthFirst[E cmp.Ordered](node Node[E], v func(node Node[E]) bool) bool
- func InOrder[E cmp.Ordered](node Node[E], v func(node Node[E]) bool) bool
- func InsertAll[E cmp.Ordered](t canopy.Tree[E], values ...E)
- func PostOrder[E cmp.Ordered](node Node[E], v func(node Node[E]) bool) bool
- func PreOrder[E cmp.Ordered](node Node[E], v func(node Node[E]) bool) bool
- func PrintTree[E cmp.Ordered](tree Traverser[E])
- type BSTree
- type Node
- type RBTree
- type RedBlackTree
- type SplayTree
- type Traverser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BreadthFirst ¶
BreadthFirst traverses a binary tree with breadth first ordering.
Types ¶
type BSTree ¶
BSTree is a binary search tree.
func NewBinarySearchTree ¶
NewBinarySearchTree creates a binary search tree.
type RBTree ¶
RBTree a struct for red black trees. Red Black Trees have the following properties: 1) Every node is either red or black. 2) nil nodes are considered black 3) A red node cannot have a red child 4) The path from any given node goes through the same number of black nodes. 5) If a node has a single child, it must be a red child.
type RedBlackTree ¶
func NewRedBlackTree ¶
func NewRedBlackTree[E cmp.Ordered]() *RedBlackTree[E]
NewRedBlackTree creates a new red black tree.
func (*RedBlackTree[E]) Delete ¶
func (t *RedBlackTree[E]) Delete(value E) bool
func (*RedBlackTree[E]) Find ¶
func (t *RedBlackTree[E]) Find(value E) bool
func (*RedBlackTree[E]) Insert ¶
func (t *RedBlackTree[E]) Insert(value E) bool
type SplayTree ¶
SplayTree A splay tree where the most recently accessed bsNode is rotated to the root. A splay tree does not have to be in strict balance.
func NewSplayTree ¶
func (*SplayTree[E]) Delete ¶
Delete Remove nodes from the splay tree. Based off the wikipedia description: https://en.wikipedia.org/wiki/Splay_tree#Deletion
type Traverser ¶
type Traverser[E cmp.Ordered] interface { Traverse(method func(node Node[E], v func(node Node[E]) bool) bool, visitor func(node Node[E]) bool) }
Traverser provides a method to traverse any binary tree. method defines how the tree is traversed: PreOrder, InOrder, PostOrder, or BreadthFirst. visitor is a user defined implementation called on each node in the binary tree.