Helpers to get the rightmost and leftmost node
This, due to the properties of a cw tree, will be the largest and smallest fraction of the tree.
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -31,6 +31,22 @@
|
||||
#define LINE_TOP (7 * HEIGHT / 16)
|
||||
#define LINE_BOTTOM (9 * HEIGHT / 16)
|
||||
|
||||
Node rightmost_node(const NodeAllocator &allocator)
|
||||
{
|
||||
auto node = allocator.getVal(0);
|
||||
while (node.right.has_value())
|
||||
node = allocator.getVal(node.right.value());
|
||||
return node;
|
||||
}
|
||||
|
||||
Node leftmost_node(const NodeAllocator &allocator)
|
||||
{
|
||||
auto node = allocator.getVal(0);
|
||||
while (node.left.has_value())
|
||||
node = allocator.getVal(node.left.value());
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user