30 TreeNode(std::size_t node_number, std::size_t representation_position)
31 :
number(node_number),
pos(representation_position) {}
51 Node
root()
const {
return impl().root_impl(); }
57 std::size_t
size()
const {
return impl().size_impl(); }
70 bool is_leaf(
const Node& node)
const {
return impl().is_leaf_impl(node); }
77 bool is_root(
const Node& node)
const {
return impl().is_root_impl(node); }
84 std::size_t
degree(
const Node& node)
const {
85 return impl().degree_impl(node);
94 return impl().first_child_impl(node);
103 Node
child(
const Node& node, std::size_t index)
const {
104 return impl().child_impl(node, index);
112 Node
parent(
const Node& node)
const {
return impl().parent_impl(node); }
120 return impl().is_last_child_impl(node);
129 return impl().next_sibling_impl(node);
134 const Impl& impl()
const {
return static_cast<const Impl&
>(*this); }
CRTP facade for rooted ordered trees.
Definition tree.h:43
bool is_leaf(const Node &node) const
Check whether node has no children.
Definition tree.h:70
bool is_root(const Node &node) const
Check whether node is the root.
Definition tree.h:77
Node first_child(const Node &node) const
Return the first child of node.
Definition tree.h:93
std::size_t degree(const Node &node) const
Return the number of children of node.
Definition tree.h:84
std::size_t size() const
Return the number of nodes.
Definition tree.h:57
Node next_sibling(const Node &node) const
Return the next sibling of node.
Definition tree.h:128
bool empty() const
Check whether the tree contains no nodes.
Definition tree.h:63
Node parent(const Node &node) const
Return the parent of node.
Definition tree.h:112
Node root() const
Return the root node.
Definition tree.h:51
bool is_last_child(const Node &node) const
Check whether node is its parent's last child.
Definition tree.h:119
Node child(const Node &node, std::size_t index) const
Return a child of node by zero-based index.
Definition tree.h:103
Logical node handle shared by succinct rooted-tree encodings.
Definition tree.h:18
std::size_t number
Logical node number in the encoding's traversal order.
Definition tree.h:20
std::size_t pos
Bit position representing the node in the succinct encoding.
Definition tree.h:23
TreeNode(std::size_t node_number, std::size_t representation_position)
Construct a node handle.
Definition tree.h:30