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) AuthWalk(fn func(*Elem, map[uint16][]dns.RR, bool) error) error
- func (t *Tree) Delete(rr dns.RR)
- func (t *Tree) DeleteMax()
- func (t *Tree) DeleteMin()
- func (t *Tree) Glue(nsrrs []dns.RR, do bool) []dns.RR
- 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)
- func (t *Tree) Walk(fn func(*Elem, map[uint16][]dns.RR) error) error
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) Empty ¶
Empty returns true is e does not contain any RRs, i.e. is an empty-non-terminal.
func (*Elem) Insert ¶
Insert inserts rr into e. If rr is equal to existing RRs, the RR will be added anyway.
func (*Elem) TypeForWildcard ¶
TypeForWildcard returns the RRs with type qtype from e. The ownername returned is set to qname.
type Tree ¶
A Tree manages the root node of an LLRB tree. Public methods are exposed through this type.
func (*Tree) AuthWalk ¶
AuthWalk performs fn on all authoritative values stored in the tree in pre-order depth first. If a non-nil error is returned the AuthWalk was interrupted by an fn returning that error. If fn alters stored values' sort relationships, future tree operation behaviors are undefined.
The fn function will be called with 3 arguments, the current element, a map containing all the RRs for this element and a boolean if this name is considered authoritative.
func (*Tree) Delete ¶
Delete removes all RRs of type rr.Header().Rrtype from e. If after the deletion of rr the node is empty the entire node is deleted.
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) 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().
func (*Tree) Prev ¶
Prev returns the greatest value equal to or less than the qname according to Less().