avl

package
v0.0.0-...-d75304e Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AVL

type AVL struct {
	// contains filtered or unexported fields
}

AVL type represents a container for an AVL tree.

func NewAVL

func NewAVL() *AVL

NewAVL returns a new and empty AVL tree. Additionally, the exported AVL functions will be registered as callable Javascript functions. This allows the AVL library to function as a WASM module.

func (*AVL) Ascending

func (t *AVL) Ascending() []interface{}

Ascending is a wrapper function for the recursive ascending traversal function.

func (*AVL) AscendingJS

func (t *AVL) AscendingJS(this js.Value, args []js.Value) interface{}

AscendingJS is a wrapper function for the AVL tree Ascending traversal.

func (*AVL) Descending

func (t *AVL) Descending() []interface{}

Descending is a wrapper function for recursive descending traversal function.

func (*AVL) DescendingJS

func (t *AVL) DescendingJS(this js.Value, args []js.Value) interface{}

DescendingJS is a wrapper function for the AVL tree Descending traversal.

func (*AVL) GetHeight

func (t *AVL) GetHeight() float64

GetHeight returns the height of the tree.

func (*AVL) GetSize

func (t *AVL) GetSize() int

GetSize returns the number of nodes in the tree.

func (*AVL) Insert

func (t *AVL) Insert(basicData interface{})

Insert is a wrapper function for the recursive insert function. It converts the argument data (basicData) passed in into a generic form, then passes it to the recursive insert function.

func (*AVL) InsertJS

func (t *AVL) InsertJS(this js.Value, args []js.Value) interface{}

InsertJS is a wrapper function for the AVL tree Insert.

func (*AVL) LevelOrder

func (t *AVL) LevelOrder() []interface{}

LevelOrder is an iterative function which traverses the AVL tree in level-order, appending each element within a level to a slice, and appending each slice to another slice. This slice of slices is returned once the traversal is finished. In normal terms, the return type is just a 2D-array where each array represents a level, and the elements within each array represent the elements within a level. This traversal is achieved by using the BFS algorithm.

func (*AVL) LevelOrderJS

func (t *AVL) LevelOrderJS(this js.Value, args []js.Value) interface{}

LevelOrderJS is a wrapper function for the AVL tree LevelOrder traversal.

func (*AVL) Postorder

func (t *AVL) Postorder() []interface{}

Postorder is a wrapper function for recursive postorder traversal function.

func (*AVL) PostorderJS

func (t *AVL) PostorderJS(this js.Value, args []js.Value) interface{}

PostorderJS is a wrapper function for the AVL tree Postorder traversal.

func (*AVL) Preorder

func (t *AVL) Preorder() []interface{}

Preorder is a wrapper function for recursive preorder traversal function.

func (*AVL) PreorderJS

func (t *AVL) PreorderJS(this js.Value, args []js.Value) interface{}

PreorderJS is a wrapper function for the AVL tree Preorder traversal.

func (*AVL) Remove

func (t *AVL) Remove(basicData interface{}) bool

Remove is a wrapper function for the recursive remove function. It converts the argument data (basicData) passed in into a generic form, then passes it to the recursive remove function.

func (*AVL) RemoveJS

func (t *AVL) RemoveJS(this js.Value, args []js.Value) interface{}

RemoveJS is a wrapper function for the AVL tree Remove.

func (*AVL) Retrieve

func (t *AVL) Retrieve(basicData interface{}) interface{}

Retrieve is a wrapper function for recursive retrieve function. It converts the argument data (basicData) passed in into a generic form, then passes it to the recursive retrieve function.

func (*AVL) RetrieveJS

func (t *AVL) RetrieveJS(this js.Value, args []js.Value) interface{}

RetrieveJS is a wrapper function for the AVL tree Retrieve.

type Float

type Float float64

Float type allows float comparison through Float method "Less"

func (Float) Less

func (a Float) Less(b Interface) bool

Less returns true if a < b. Assume a, b are Float.

type Int

type Int int

Int type allows int comparison through Int method "Less"

func (Int) Less

func (a Int) Less(b Interface) bool

Less returns true if a < b. Assume a, b are Int.

type Interface

type Interface interface {
	Less(toCompare Interface) bool
}

Interface type allows comparison between keys in generic form.

type Object

type Object js.Value

Object type allows js.Value comparison through Object method "Less"

func (Object) Less

func (a Object) Less(b Interface) bool

Less returns true if a is less than b by whatever metric the user has defined for this datatype. Assume a, b are Object.

type String

type String string

String type allows string comparison through String method "Less"

func (String) Less

func (a String) Less(b Interface) bool

Less returns true if a < b. Assume a, b are String.

Jump to

Keyboard shortcuts

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