bst

package
v0.0.0-...-a3940bd Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 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 Node

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

Node represents a node in Tree.

func (*Node) Depth

func (n *Node) Depth(root trees.Node) int

func (*Node) Height

func (n *Node) Height() int

Height returns the height of n.

func (*Node) IsLeaf

func (n *Node) IsLeaf() bool

func (*Node) IsNil

func (n *Node) IsNil() bool

func (*Node) Value

func (n *Node) Value() interface{}

Value returns the value stored in n.

func (*Node) VisitInOrder

func (n *Node) VisitInOrder(consumer func(interface{}))

VisitInOrder traverses the subtree rooted at n in in-order (LNR).

func (*Node) VisitPostOrder

func (n *Node) VisitPostOrder(consumer func(interface{}))

VisitPostOrder traverses the subtree rooted at n in post-order (LRN).

func (*Node) VisitPreOrder

func (n *Node) VisitPreOrder(consumer func(interface{}))

VisitPreOrder traverses the subtree rooted at n in pre-order (NLR).

type Tree

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

Tree implements an unbalanced binary search tree.

func New

func New(less func(interface{}, interface{}) bool) *Tree

func (*Tree) Cap

func (t *Tree) Cap() int

Cap returns the capacity of t. It is always the same as t.Len().

func (*Tree) Delete

func (t *Tree) Delete(x interface{}) trees.Node

func (*Tree) Find

func (t *Tree) Find(x interface{}) trees.Node

func (*Tree) Glb

func (t *Tree) Glb(x interface{}) trees.Node

func (*Tree) GlbEq

func (t *Tree) GlbEq(x interface{}) trees.Node

func (*Tree) Insert

func (t *Tree) Insert(x interface{}) trees.Node

func (*Tree) IsEmpty

func (t *Tree) IsEmpty() bool

IsEmpty returns whether t is empty.

func (*Tree) IsFull

func (t *Tree) IsFull() bool

IsFull returns whether t is full. It always returns false.

func (*Tree) Len

func (t *Tree) Len() int

Len returns the number of elements in t. The time complexity is O(1).

func (*Tree) Lub

func (t *Tree) Lub(x interface{}) trees.Node

func (*Tree) LubEq

func (t *Tree) LubEq(x interface{}) trees.Node

func (*Tree) Max

func (t *Tree) Max() interface{}

func (*Tree) Min

func (t *Tree) Min() interface{}

func (*Tree) VisitInOrder

func (t *Tree) VisitInOrder(consumer func(interface{}))

func (*Tree) VisitPostOrder

func (t *Tree) VisitPostOrder(consumer func(interface{}))

func (*Tree) VisitPreOrder

func (t *Tree) VisitPreOrder(consumer func(interface{}))

Jump to

Keyboard shortcuts

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