Documentation
¶
Overview ¶
AVLTree are associative containers that store elements formed by a combination of a key value and a mapped value, following a specific order. In a AVLTree, the key values are generally used to sort and uniquely identify the elements, while the mapped values store the content associated to this key. The types of key and mapped value may differ. Internally, the elements in a AVLTree are always sorted by its key following a specific strict weak ordering criterion indicated by its internal comparison object (of type Comparator). AVLTree containers are generally slower than go map container to access individual elements by their key, but they allow the direct iteration on subsets based on their order.
Index ¶
- type AVLTree
- func (t *AVLTree) BSTDump(w io.Writer)
- func (t *AVLTree) CheckHeight(checker heightChecker)
- func (t *AVLTree) Clear()
- func (t *AVLTree) Contains(key interface{}) bool
- func (t *AVLTree) Empty() bool
- func (t *AVLTree) EnumerateAsc(f Enumerator)
- func (t *AVLTree) EnumerateDesc(f Enumerator)
- func (t *AVLTree) Erase(key interface{}) error
- func (t *AVLTree) Find(key interface{}) interface{}
- func (t *AVLTree) Insert(key interface{}, value interface{}) error
- func (t *AVLTree) Size() uint
- type Comparator
- type Enumerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AVLTree ¶
type AVLTree struct {
// contains filtered or unexported fields
}
AVLTree is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted by using the comparison function `Comparator`. Search, removal, and insertion operations have logarithmic complexity.
func NewAVLTree ¶
func NewAVLTree(c Comparator) *AVLTree
Creates a new AVLTree instance with the given Comparator
func (*AVLTree) BSTDump ¶
Writes BST Tree for graphviz visualizator See here https://graphviz.org/ for the details
func (*AVLTree) CheckHeight ¶
func (t *AVLTree) CheckHeight(checker heightChecker)
Test stuff. You do need to use it
func (*AVLTree) EnumerateAsc ¶ added in v0.0.2
func (t *AVLTree) EnumerateAsc(f Enumerator)
Calls 'Enumerator' for every Tree's element in ascending order
func (*AVLTree) EnumerateDesc ¶ added in v0.0.2
func (t *AVLTree) EnumerateDesc(f Enumerator)
Calls 'Enumerator' for every Tree's element in descending order
func (*AVLTree) Find ¶
func (t *AVLTree) Find(key interface{}) interface{}
Finds element with specific key Returns an interface{} for associtaed with the key value. When key isn't present returns nil
type Comparator ¶
type Comparator func(a interface{}, b interface{}) int
Function type that whould be defined for a key type in the tree
type Enumerator ¶ added in v0.0.2
type Enumerator func(key interface{}, value interface{}) bool
Function type for AVLTree traversal