Documentation ¶
Overview ¶
Package avltree provides an universal AVL tree
Index ¶
- type Comparable
- type EachFunc
- type Tree
- func (t *Tree) Dump() (res []interface{})
- func (t *Tree) Each(f EachFunc, vals ...interface{})
- func (t *Tree) Exists(key interface{}) bool
- func (t *Tree) Insert(key interface{}, value interface{}, issmaller Comparable) (new *TreeNode, err error)
- func (t *Tree) Intersection(x *Tree) (res *Tree)
- func (t *Tree) TopN(n int) (res []interface{})
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparable ¶
type Comparable func(c1 interface{}, c2 interface{}) bool
Comparable is an interface used to pass compare functions to this avltree
type EachFunc ¶
type EachFunc func(node *TreeNode, vals ...interface{})
EachFunc is an interface used to pass a function to the each() method
type Tree ¶
type Tree struct { Count int // contains filtered or unexported fields }
Tree represents a tree
func Intersection ¶
Intersection builds a tree of common elements of all trees in `candidates`
func (*Tree) Dump ¶
func (t *Tree) Dump() (res []interface{})
Dump dumps tree `t` into a slice and returns it
func (*Tree) Each ¶
Each can be used to traverse tree `t` and call function f with params vals... for each node in the tree
func (*Tree) Insert ¶
func (t *Tree) Insert(key interface{}, value interface{}, issmaller Comparable) (new *TreeNode, err error)
Insert inserts an element to tree with root `t`
func (*Tree) Intersection ¶
Intersection finds common elements in trees `t` and `x` and returns them in a new tree
Click to show internal directories.
Click to hide internal directories.