Documentation
¶
Index ¶
- type AATree
- func (t *AATree[X]) After(data X) (X, bool)
- func (t *AATree[X]) Before(data X) (X, bool)
- func (t *AATree[X]) Clear()
- func (t *AATree[X]) Count() int
- func (t *AATree[X]) EqualAfter(data X) (X, bool)
- func (t *AATree[X]) EqualBefore(data X) (X, bool)
- func (t *AATree[X]) Get(data X) (out X, ok bool)
- func (t *AATree[X]) Has(data X) bool
- func (t *AATree[X]) High() (out X, ok bool)
- func (t *AATree[X]) Insert(data X) bool
- func (t *AATree[X]) Iter() iter.Seq[X]
- func (t *AATree[X]) Low() (out X, ok bool)
- func (t *AATree[X]) Remove(data X) bool
- type CompareFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AATree ¶
type AATree[X any] struct { // contains filtered or unexported fields }
AATree represents an AA tree structure. The generic type X is the type of data stored in the tree.
func New ¶ added in v0.1.34
func New[X any](compare CompareFunc[X]) *AATree[X]
New creates a new, empty AA tree with the given comparison function.
func (*AATree[X]) After ¶ added in v0.1.34
After finds the node immediately after the passed data. It returns a pointer to the data, or nil if not found or tree is empty.
func (*AATree[X]) Before ¶
Before finds the node immediately before the passed data. It returns a pointer to the data, or nil if not found or tree is empty.
func (*AATree[X]) EqualAfter ¶ added in v0.1.34
EqualAfter finds the node with the given data or the node closest above the passed argument. It returns a pointer to the data, or nil if not found or tree is empty.
func (*AATree[X]) EqualBefore ¶ added in v0.1.34
EqualBefore finds the node with the given data or the node closest before the passed argument. It returns a pointer to the data, or nil if not found or tree is empty.
func (*AATree[X]) Get ¶ added in v0.1.34
Get checks if this tree contains the given data, based on the compare function. Returns the previously added data for this node.
func (*AATree[X]) Has ¶
Has checks if this tree contains the given data, based on the compare function.
func (*AATree[X]) Insert ¶
Insert inserts the value into the tree. It updates the previous value if the compare function returns zero. Returns true if a new node was inserted. This returns false if the node already existed, however, the data might still have changed (it just compared as equal).
type CompareFunc ¶
CompareFunc is a function type that compares two elements of type X. It should return:
- a negative integer if a < b
- zero if a == b
- a positive integer if a > b