Documentation ¶
Overview ¶
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
More details relating to the implementation are available at the following locations:
http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf http://www.cs.princeton.edu/~rs/talks/LLRB/Java/RedBlackBST.java http://www.teachsolaisgames.com/articles/balanced_left_leaning.html
Heavily modified by Miek Gieben for use in DNS zones.
Index ¶
- func Less(a *Elem, name string) int
- type Color
- type Elem
- type Node
- type Tree
- func (t *Tree) All() []*Elem
- func (t *Tree) Delete(rr dns.RR)
- func (t *Tree) DeleteMax()
- func (t *Tree) DeleteMin()
- func (t *Tree) Do(fn func(e *Elem) bool) bool
- func (t *Tree) Insert(rr dns.RR)
- func (t *Tree) Len() int
- func (t *Tree) Max() *Elem
- func (t *Tree) Min() *Elem
- func (t *Tree) Next(qname string) (*Elem, bool)
- func (t *Tree) Prev(qname string) (*Elem, bool)
- func (t *Tree) Print()
- func (t *Tree) Search(qname string) (*Elem, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Elem ¶
type Elem struct {
// contains filtered or unexported fields
}
Elem is an element in the tree.
func (*Elem) Delete ¶
Delete removes rr from e. When e is empty after the removal the returned bool is true.
func (*Elem) Empty ¶
Empty returns true is e does not contain any RRs, i.e. is an empty-non-terminal.
type Tree ¶
A Tree manages the root node of an LLRB tree. Public methods are exposed through this type.
func (*Tree) Delete ¶
Delete removes rr from the tree, is the node turns empty, that node is deleted with DeleteNode.
func (*Tree) DeleteMax ¶
func (t *Tree) DeleteMax()
DeleteMax deletes the node with the maximum value in the tree.
func (*Tree) DeleteMin ¶
func (t *Tree) DeleteMin()
DeleteMin deletes the node with the minimum value in the tree.
func (*Tree) Do ¶
Do performs fn on all values stored in the tree. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships, future tree operation behaviors are undefined.
func (*Tree) Insert ¶
Insert inserts rr into the Tree at the first match found with e or when a nil node is reached.
func (*Tree) Next ¶
Next returns the smallest value equal to or greater than the qname according to Less().