bst

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 3 Imported by: 0

README

bst

Go binary search tree.

Only implement AVLTree using generic.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AVLTree

type AVLTree[K constraints.Ordered, T any] struct {
	// contains filtered or unexported fields
}

AVLTree the binary search tree of Items

func (*AVLTree[K, T]) FloorCeil

func (bst *AVLTree[K, T]) FloorCeil(key K) (floorIt, ceilIt Iterator[K, T])

func (*AVLTree[K, T]) InOrderTraverse

func (bst *AVLTree[K, T]) InOrderTraverse(f func(T))

InOrderTraverse visits all nodes with in-order traversing

func (*AVLTree[K, T]) Insert

func (bst *AVLTree[K, T]) Insert(key K, value T)

Insert inserts the Item t in the tree

func (*AVLTree[K, T]) Max

func (bst *AVLTree[K, T]) Max() Iterator[K, T]

Max returns the Item with max value stored in the tree

func (*AVLTree[K, T]) Min

func (bst *AVLTree[K, T]) Min() Iterator[K, T]

Min returns the Item with min value stored in the tree

func (*AVLTree[K, T]) PostOrderTraverse

func (bst *AVLTree[K, T]) PostOrderTraverse(f func(T))

PostOrderTraverse visits all nodes with post-order traversing

func (*AVLTree[K, T]) PreOrderTraverse

func (bst *AVLTree[K, T]) PreOrderTraverse(f func(T))

PreOrderTraverse visits all nodes with pre-order traversing

func (*AVLTree[K, T]) Remove

func (bst *AVLTree[K, T]) Remove(key K)

Remove removes the Item with key `key` from the tree

func (*AVLTree[K, T]) Search

func (bst *AVLTree[K, T]) Search(key K) Iterator[K, T]

Search returns true if the Item t exists in the tree

func (*AVLTree[K, T]) Size

func (bst *AVLTree[K, T]) Size() int

func (*AVLTree[K, T]) String

func (bst *AVLTree[K, T]) String()

String prints a visual representation of the tree

type Iterator

type Iterator[K constraints.Ordered, T any] struct {
	// contains filtered or unexported fields
}

func (*Iterator[K, T]) End

func (it *Iterator[K, T]) End() bool

func (*Iterator[K, T]) Key

func (it *Iterator[K, T]) Key() K

func (*Iterator[K, T]) Next

func (it *Iterator[K, T]) Next() Iterator[K, T]

func (*Iterator[K, T]) Prev

func (it *Iterator[K, T]) Prev() Iterator[K, T]

func (*Iterator[K, T]) Value

func (it *Iterator[K, T]) Value() T

type Node

type Node[K constraints.Ordered, T any] struct {
	// contains filtered or unexported fields
}

Node a single node that composes the tree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL