binary

package
v0.0.0-...-9b8d98b Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinTree

type BinTree struct {
	Element
}

BinTree represents a binary tree. The zero value for tree is an empty tree ready to use.

func New

func New(v interface{}) *BinTree

New returns an empty tree

func (*BinTree) Depth

func (b *BinTree) Depth() int

Depth return the depth

func (*BinTree) Init

func (b *BinTree) Init() *BinTree

Init initializes a tree.

func (*BinTree) InorderTraverse

func (b *BinTree) InorderTraverse(visit func(e *Element))

func (*BinTree) InorderTraverseIteration

func (b *BinTree) InorderTraverseIteration(visit func(e *Element))

func (*BinTree) LevelorderTraverse

func (b *BinTree) LevelorderTraverse(visit func(e *Element))

func (*BinTree) PostorderTraverse

func (b *BinTree) PostorderTraverse(visit func(e *Element))

func (*BinTree) PostorderTraverseIteration

func (b *BinTree) PostorderTraverseIteration(visit func(e *Element))

func (*BinTree) PreorderTraverse

func (b *BinTree) PreorderTraverse(visit func(e *Element))

PreorderTraverse visit element with recursive pre-order

func (*BinTree) PreorderTraverseIteration

func (b *BinTree) PreorderTraverseIteration(visit func(e *Element))

type Element

type Element struct {

	// The value stored with this element.
	Value interface{}
	// contains filtered or unexported fields
}

Element is an element of a binary tree.

func NewElement

func NewElement(v interface{}) *Element

func (*Element) Left

func (e *Element) Left() *Element

Left returns the left child or nil.

func (*Element) Right

func (e *Element) Right() *Element

Right returns the right child or nil.

Jump to

Keyboard shortcuts

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