Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
Tree represents a binary search tree (BST) structure. This structure facilitates the traversal of elements in order.
func (*Tree[K, V]) Find ¶
Find finds an element from the BST. The performance of the find operation highly depends on the order of insertion, as a BST isn't a balanced structure. In cases where the element is not present in the tree, a zero value with a `false` boolean will be returned.
func (*Tree[K, V]) Insert ¶
func (t *Tree[K, V]) Insert(key K, val V)
Insert adds an element to the BST.
func (*Tree[K, V]) Remove ¶
Remove deletes an element from the BST. The performance of the delete operation highly depends on the order of insertion, as a BST isn't a balanced structure. In cases where the element is not present in the tree, a zero value with a `false` boolean will be returned. If the object is found, it is removed from the structure and returned.