|
Recti 1.2.4
|
Arena-allocated tree of TreeNodes.
More...
#include <dme_algorithm.hpp>
Public Member Functions | |
| Tree ()=default | |
| NodeIdx | add (TreeNode node) |
| Adds a node to the arena and returns its index. | |
| const TreeNode & | get (NodeIdx idx) const |
| Returns a const reference to the node at the given index. | |
| TreeNode & | get_mut (NodeIdx idx) |
| Returns a mutable reference to the node at the given index. | |
| std::pair< TreeNode &, TreeNode & > | get_pair_mut (NodeIdx a, NodeIdx b) |
| Simultaneously returns mutable references to two distinct nodes. | |
| std::size_t | size () const |
| Number of nodes in the arena. | |
| bool | empty () const |
| True when the arena holds no nodes. | |
Public Attributes | |
| NodeIdx | root = SIZE_MAX |
Arena-allocated tree of TreeNodes.
Nodes are stored in a contiguous std::vector and referenced by their NodeIdx index. This avoids std::shared_ptr overhead, improves cache locality, and allows safe simultaneous mutation of two distinct nodes via get_pair_mut.
|
default |
Adds a node to the arena and returns its index.
| node | The node to add. |
|
inline |
True when the arena holds no nodes.
Returns a const reference to the node at the given index.
Returns a mutable reference to the node at the given index.
Simultaneously returns mutable references to two distinct nodes.
Safe because distinct vector elements are independent in C++.
| std::out_of_range | if either index is out of bounds. |
|
inline |
Number of nodes in the arena.
| NodeIdx recti::Tree::root = SIZE_MAX |
Index of the root node, or SIZE_MAX if the tree is empty.