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) 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(e *Elem, rrs 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 ¶ added in v1.6.0
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) 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().