Documentation
¶
Index ¶
- func Ancestor(i, tiersUp int) int
- func Left(i int) int
- func Parent(i int) int
- func Right(i int) int
- type BST
- func (b *BST) Copy() interface{}
- func (b *BST) InOrderTraverse() []search.Node
- func (b *BST) Search(key interface{}) (bool, interface{})
- func (b *BST) SearchDown(key interface{}, down int) (search.Comparable, interface{})
- func (b *BST) SearchUp(key interface{}, up int) (search.Comparable, interface{})
- func (b *BST) Size() int
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ancestor ¶
Ancestor returns the index representing this node's ancestor of N generations equivalent to calling Parent tiersUp times
Types ¶
type BST ¶
type BST []*Node
BST in static is an array-based BST, as opposed to a pointer-based BST.
func (*BST) InOrderTraverse ¶
InOrderTraverse : There are multiple ways to traverse a tree. The most useful of these is the in-order traverse, and that's what we provide here. Other traversal methods can be added as needed.
func (*BST) Search ¶
Search : Search returns the first value of the given key found in the tree. No guarantee is made about what is returned if multiple nodes share the input key. If no key is found, returns (false, nil).
Value vs pointer reciever was benchmarked. Result: maybe pointer is better
func (*BST) SearchDown ¶
func (b *BST) SearchDown(key interface{}, down int) (search.Comparable, interface{})
SearchDown performs a search and rounds down by 'down' steps.