Documentation
¶
Index ¶
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 NewAATree ¶
func NewAATree[X any](compare CompareFunc[X]) *AATree[X]
NewAATree creates a new, empty AA tree with the given comparison function.
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]) Find ¶
Find 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]) Has ¶
Has checks if this tree contains the given data, based on the compare function.
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