Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RBTree ¶
type RBTree[T comparable] struct { // contains filtered or unexported fields }
func NewRBTreeWithComparator ¶
func NewRBTreeWithComparator[T comparable](comparator utility.Compare[T], allowDuplicates bool) *RBTree[T]
NewRBTreeWithComparator creates an empty tree with provided comparator for items.
func (*RBTree[T]) Erase ¶
func (rbt *RBTree[T]) Erase(value T)
Erase deletes the item from the tree. Has no effect if the item was not in the tree. Complexity O(log n), where n is the number of elements in the tree.
func (*RBTree[T]) Find ¶
Find tries to find the value in the tree. Returns 2 values. First value is an item if it was found, otherwise zero value for type parameter. Second value is bool indicating whether an item was found. Complexity O(log n), where n is the number of elements in the tree.
func (*RBTree[T]) Insert ¶
func (rbt *RBTree[T]) Insert(value T)
Insert adds value into the tree. Complexity O(log n), where n is the number of elements in the tree.
func (*RBTree[T]) Max ¶
func (rbt *RBTree[T]) Max() T
Max returns max item in the tree according to the comparator. Complexity O(log n), where n is the number of elements in tree.