Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryTree ¶
type BinaryTree[T any] struct { // contains filtered or unexported fields }
BinaryTree Simple Binary Tree, must define the comparator function (must be true for larger value), and equalizer function
func NewBinarySearchTree ¶
func NewBinarySearchTree[T any](compareFunction, equals func(T, T) bool) *BinaryTree[T]
NewBinarySearchTree Creates an empty Binary Search tree
func (BinaryTree[T]) InorderPrint ¶
func (b BinaryTree[T]) InorderPrint()
InorderPrint Outputs the tree in order of seeing each node
func (*BinaryTree[T]) Insert ¶
func (b *BinaryTree[T]) Insert(value T)
Insert Inserts a new value into the tree, using the comparator function saved in the struct
func (BinaryTree[T]) PostorderPrint ¶
func (b BinaryTree[T]) PostorderPrint()
PostorderPrint Outputs the tree with the root node coming last
func (BinaryTree[T]) PreorderPrint ¶
func (b BinaryTree[T]) PreorderPrint()
PreorderPrint Outputs the tree with the root node coming first
func (*BinaryTree[T]) Remove ¶
func (b *BinaryTree[T]) Remove(value T)
Remove the value from location, and replace with best replacement
func (*BinaryTree[T]) Search ¶
func (b *BinaryTree[T]) Search(value T) bool
Search returns the binary node containing the value given, nil otherwise
func (BinaryTree[T]) VisualizeDotty ¶
func (b BinaryTree[T]) VisualizeDotty(fileName string)
Visualize creates a dotty file and runs the dot program (please make sure to have GraphViz initialized)