Documentation
¶
Index ¶
- type Node
- type Tree
- func (t *Tree) AnnotatedString() string
- func (t *Tree) CutOffRange(fromOuter, fromInner, toInner, toOuter *Node)
- func (t *Tree) Delete(node *Node)
- func (t *Tree) Find(index int) (*Node, int)
- func (t *Tree) IndexOf(node *Node) int
- func (t *Tree) Insert(node *Node) *Node
- func (t *Tree) InsertAfter(prev *Node, node *Node) *Node
- func (t *Tree) Splay(node *Node)
- func (t *Tree) String() string
- func (t *Tree) UpdateWeight(node *Node)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is weighted binary search tree which is based on Splay tree. original paper on Splay Trees:
func (*Tree) AnnotatedString ¶
AnnotatedString returns a string containing the metadata of the Node for debugging purpose.
func (*Tree) CutOffRange ¶ added in v0.2.8
CutOffRange cuts the given range from this Tree. This function separates the range from `fromInner` to `toInner` as a subtree by splaying outer nodes then cuts the subtree. 'xxxOuter' could be nil and means to delete the entire subtree in that direction.
CAUTION: This function does not filter out invalid argument inputs, such as non-consecutive indices in fromOuter and fromInner.
func (*Tree) InsertAfter ¶
InsertAfter inserts the node after the given previous node.
func (*Tree) UpdateWeight ¶ added in v0.2.8
UpdateWeight recalculates the weight of this node with the value and children.