Documentation ¶
Index ¶
- type AvlTree
- func (tree *AvlTree[T]) Add(value T)
- func (tree *AvlTree[T]) Clear()
- func (tree *AvlTree[T]) Contains(value T) bool
- func (tree *AvlTree[T]) GetMax() (T, error)
- func (tree *AvlTree[T]) GetMin() (T, error)
- func (tree *AvlTree[T]) InOrderTraverse() []T
- func (tree *AvlTree[T]) IsEmpty() bool
- func (tree *AvlTree[T]) NewIterator() *AvlTreeIterator[T]
- func (tree *AvlTree[T]) Remove(value T) bool
- func (tree *AvlTree[T]) Size() int
- type AvlTreeIterator
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvlTree ¶
type AvlTree[T constraints.Ordered] struct { // contains filtered or unexported fields }
func NewAvlTree ¶
func NewAvlTree[T constraints.Ordered]() *AvlTree[T]
func (*AvlTree[T]) Add ¶
func (tree *AvlTree[T]) Add(value T)
Insert a node with the given value and rebalance the tree.
func (*AvlTree[T]) InOrderTraverse ¶ added in v1.0.0
func (tree *AvlTree[T]) InOrderTraverse() []T
Returns a slice of the tree's values in-order. Appends to the provided pointer to a slice. If the pointer is nil, a new slice is created.
func (*AvlTree[T]) NewIterator ¶
func (tree *AvlTree[T]) NewIterator() *AvlTreeIterator[T]
Returns a new iterator for the tree. Call Next() on the iterator to get the next value in the tree in-order.
type AvlTreeIterator ¶
type AvlTreeIterator[T constraints.Ordered] struct { // contains filtered or unexported fields }
func (*AvlTreeIterator[T]) Next ¶
func (iter *AvlTreeIterator[T]) Next() (T, int)
Returns the next value in the tree and its index in the in-order traversal from the iterator. If the end of the tree is reached, the zero value of the type is returned and -1 is returned as the index.
type Node ¶
type Node[T constraints.Ordered] struct { // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.