cr8r_avl_node Struct Reference

An avl tree node, also used to store an entire tree by synecdoche. More...

Data Fields

cr8r_avl_nodeleft
 Pointers to other nodes (can be NULL)
 
cr8r_avl_noderight
 Pointers to other nodes (can be NULL)
 
cr8r_avl_nodeparent
 Pointers to other nodes (can be NULL)
 
signed char balance
 avl balance value; the height of the right subtree minus the height of the left subtree. More...
 
char data []
 element data
 

Detailed Description

An avl tree node, also used to store an entire tree by synecdoche.

The data field is a flexible length array in which any element type (uint64_t, custom struct, etc) can be stored. Since avl tree are often used as ordered maps, the thing stored in the data field is often referred to as the "element" of the node because it is an element of the ordered map represented by the tree. It is also often referred to as the "key" (especially in parameter names) or the "value". Properly, the "key" is whatever part of the element the comparison function cares about, and the "value" is the rest. There are a lot of advantages to this approach compared to the usual key, value pair approach, in particular that one struct can be used with many different key functions, such as selecting the x, y, or z coordinate of a point struct. Take care if manipulating these fields directly, this should only be done if the functions in this file are not sufficient

Definition at line 30 of file avl.h.

Field Documentation

◆ balance

signed char cr8r_avl_node::balance

avl balance value; the height of the right subtree minus the height of the left subtree.

Magnitude cannot exceed 1, providing the avl balance guarantee

Definition at line 39 of file avl.h.


The documentation for this struct was generated from the following file: