avl

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: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionalFold

func ConditionalFold(
	conditionalVisitFunc func(func(interface{}) bool) bool,
	f func(interface{}, interface{}) (bool, interface{}),
	acc0 interface{},
) (bool, interface{})

ConditionalFold TODO: Write this comment!

func ConditionalFoldNode

func ConditionalFoldNode(
	conditionalVisitNodeFunc func(func(*Node) bool) bool,
	f func(*Node, interface{}) (bool, interface{}),
	acc0 interface{},
) (bool, interface{})

ConditionalFoldNode TODO: Write this comment!

func Float64Less

func Float64Less(a interface{}, b interface{}) bool

func Fold

func Fold(
	visitFunc func(func(interface{})),
	f func(interface{}, interface{}) interface{},
	acc0 interface{},
) interface{}

Fold TODO: Write this comment!

func FoldNode

func FoldNode(
	visitNodeFunc func(func(*Node)),
	f func(*Node, interface{}) interface{},
	acc0 interface{},
) interface{}

FoldNode TODO: Write this comment!

func IntLess

func IntLess(a interface{}, b interface{}) bool

func StringLess

func StringLess(a interface{}, b interface{}) bool

Types

type Node

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

Node represents a node in Tree.

func (*Node) BalanceFactor

func (n *Node) BalanceFactor() int

BalanceFactor TODO: Write this comment!

func (*Node) ConditionalVisitInOrder

func (n *Node) ConditionalVisitInOrder(predicate func(interface{}) bool) bool

ConditionalVisitInOrder traverses the subtree rooted at n in in-order (LNR). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) ConditionalVisitNodeInOrder

func (n *Node) ConditionalVisitNodeInOrder(predicate func(*Node) bool) bool

ConditionalVisitNodeInOrder traverses the subtree rooted at n in in-order (LNR). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) ConditionalVisitNodePostOrder

func (n *Node) ConditionalVisitNodePostOrder(predicate func(*Node) bool) bool

ConditionalVisitNodePostOrder traverses the subtree rooted at n in post-order (LRN). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) ConditionalVisitNodePreOrder

func (n *Node) ConditionalVisitNodePreOrder(predicate func(*Node) bool) bool

ConditionalVisitNodePreOrder traverses the subtree rooted at n in pre-order (NLR). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) ConditionalVisitPostOrder

func (n *Node) ConditionalVisitPostOrder(predicate func(interface{}) bool) bool

ConditionalVisitPostOrder traverses the subtree rooted at n in post-order (LRN). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) ConditionalVisitPreOrder

func (n *Node) ConditionalVisitPreOrder(predicate func(interface{}) bool) bool

ConditionalVisitPreOrder traverses the subtree rooted at n in pre-order (NLR). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Node) Contains

func (n *Node) Contains(v interface{}, lessFunc func(interface{}, interface{}) bool) bool

Contains returns whether the subtree rooted at n contains v.

func (*Node) Float64Value

func (n *Node) Float64Value() float64

Float64Value TODO: Write this comment!

func (*Node) IntValue

func (n *Node) IntValue() int

IntValue TODO: Write this comment!

func (*Node) Print

func (n *Node) Print(buffer *bytes.Buffer, indentString string, indentLevel int)

Print prints the subtree rooted at n.

func (*Node) Search

func (n *Node) Search(v int, consumer func(*Node) (int, interface{})) interface{}

Search TODO: Write this comment!

func (*Node) String

func (n *Node) String() string

func (*Node) StringValue

func (n *Node) StringValue() string

StringValue TODO: Write this comment!

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) VisitNodeInOrder

func (n *Node) VisitNodeInOrder(consumer func(*Node))

VisitNodeInOrder traverses the subtree rooted at n in in-order (LNR). Any nil children of leaf nodes are also traversed.

func (*Node) VisitNodePostOrder

func (n *Node) VisitNodePostOrder(consumer func(*Node))

VisitNodePostOrder traverses the subtree rooted at n in post-order (LRN). Any nil children of leaf nodes are also traversed.

func (*Node) VisitNodePreOrder

func (n *Node) VisitNodePreOrder(consumer func(*Node))

VisitNodePreOrder traverses the subtree rooted at n in pre-order (NLR). Any nil children of leaf nodes are also traversed.

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 AVL tree.

func NewTree

func NewTree(lessFunc 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) Clone

func (t *Tree) Clone() *Tree

Clone returns a copy of t.

func (*Tree) ConditionalVisitInOrder

func (t *Tree) ConditionalVisitInOrder(predicate func(interface{}) bool) bool

ConditionalVisitInOrder traverses t in in-order (LNR). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) ConditionalVisitNodeInOrder

func (t *Tree) ConditionalVisitNodeInOrder(predicate func(*Node) bool) bool

ConditionalVisitNodeInOrder traverses t in in-order (LNR). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) ConditionalVisitNodePostOrder

func (t *Tree) ConditionalVisitNodePostOrder(predicate func(*Node) bool) bool

ConditionalVisitNodePostOrder traverses t in post-order (LRN). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) ConditionalVisitNodePreOrder

func (t *Tree) ConditionalVisitNodePreOrder(predicate func(*Node) bool) bool

ConditionalVisitNodePreOrder traverses t in pre-order (NLR). Any nil children of leaf nodes are also traversed. The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) ConditionalVisitPostOrder

func (t *Tree) ConditionalVisitPostOrder(predicate func(interface{}) bool) bool

ConditionalVisitPostOrder traverses t in post-order (LRN). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) ConditionalVisitPreOrder

func (t *Tree) ConditionalVisitPreOrder(predicate func(interface{}) bool) bool

ConditionalVisitPreOrder traverses t in pre-order (NLR). The traversal stops when predicate returns false. It returns true if predicate returns true throughout the travesal; it returns false otherwise.

func (*Tree) Contains

func (t *Tree) Contains(v interface{}) bool

Contains returns whether t contains v.

func (*Tree) Delete

func (t *Tree) Delete(v interface{})

Delete deletes v from t.

func (*Tree) Insert

func (t *Tree) Insert(v interface{})

Insert inserts v into t.

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) Print

func (t *Tree) Print(indentString string) string

Print prints t. TODO: Delete this in production

func (*Tree) String

func (t *Tree) String() string

String TODO: Write this comment!

func (*Tree) VisitInOrder

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

VisitInOrder traverses t in in-order (LNR).

func (*Tree) VisitNodeInOrder

func (t *Tree) VisitNodeInOrder(consumer func(*Node))

VisitNodeInOrder traverses t in in-order (LNR). Any nil children of leaf nodes are also traversed.

func (*Tree) VisitNodePostOrder

func (t *Tree) VisitNodePostOrder(consumer func(*Node))

VisitNodePostOrder traverses t in post-order (LRN). Any nil children of leaf nodes are also traversed.

func (*Tree) VisitNodePreOrder

func (t *Tree) VisitNodePreOrder(consumer func(*Node))

VisitNodePreOrder traverses t in pre-order (NLR). Any nil children of leaf nodes are also traversed.

func (*Tree) VisitPostOrder

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

VisitPostOrder traverses t in post-order (LRN).

func (*Tree) VisitPreOrder

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

VisitPreOrder traverses t in pre-order (NLR).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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