Pixie
Loading...
Searching...
No Matches
pixie::TreeBase< Impl > Class Template Reference

CRTP facade for rooted ordered trees. More...

#include <tree.h>

Public Types

using Node = TreeNode
 

Public Member Functions

Node root () const
 Return the root node.
 
std::size_t size () const
 Return the number of nodes.
 
bool empty () const
 Check whether the tree contains no nodes.
 
bool is_leaf (const Node &node) const
 Check whether node has no children.
 
bool is_root (const Node &node) const
 Check whether node is the root.
 
std::size_t degree (const Node &node) const
 Return the number of children of node.
 
Node first_child (const Node &node) const
 Return the first child of node.
 
Node child (const Node &node, std::size_t index) const
 Return a child of node by zero-based index.
 
Node parent (const Node &node) const
 Return the parent of node.
 
bool is_last_child (const Node &node) const
 Check whether node is its parent's last child.
 
Node next_sibling (const Node &node) const
 Return the next sibling of node.
 

Detailed Description

template<class Impl>
class pixie::TreeBase< Impl >

CRTP facade for rooted ordered trees.

Implementations may use different succinct encodings, but expose the same logical navigation operations through this facade.

See also
<pixie/tree/implementations.h> for the available succinct encodings.

Member Function Documentation

◆ child()

template<class Impl>
Node pixie::TreeBase< Impl >::child ( const Node & node,
std::size_t index ) const
inline

Return a child of node by zero-based index.

Parameters
nodeValid node handle from this tree.
indexChild index in [0, degree(node)).
Returns
Handle identifying the requested child.

◆ degree()

template<class Impl>
std::size_t pixie::TreeBase< Impl >::degree ( const Node & node) const
inline

Return the number of children of node.

Parameters
nodeValid node handle from this tree.
Returns
The node's child count.

◆ empty()

template<class Impl>
bool pixie::TreeBase< Impl >::empty ( ) const
inline

Check whether the tree contains no nodes.

Returns
true when size() == 0.

◆ first_child()

template<class Impl>
Node pixie::TreeBase< Impl >::first_child ( const Node & node) const
inline

Return the first child of node.

Parameters
nodeValid non-leaf node handle from this tree.
Returns
Handle identifying the node's first child.

◆ is_last_child()

template<class Impl>
bool pixie::TreeBase< Impl >::is_last_child ( const Node & node) const
inline

Check whether node is its parent's last child.

Parameters
nodeValid non-root node handle from this tree.
Returns
true when no sibling follows node.

◆ is_leaf()

template<class Impl>
bool pixie::TreeBase< Impl >::is_leaf ( const Node & node) const
inline

Check whether node has no children.

Parameters
nodeValid node handle from this tree.
Returns
true when the node is a leaf.

◆ is_root()

template<class Impl>
bool pixie::TreeBase< Impl >::is_root ( const Node & node) const
inline

Check whether node is the root.

Parameters
nodeValid node handle from this tree.
Returns
true when the node is the root.

◆ next_sibling()

template<class Impl>
Node pixie::TreeBase< Impl >::next_sibling ( const Node & node) const
inline

Return the next sibling of node.

Parameters
nodeValid non-root node that is not its parent's last child.
Returns
Handle identifying the next sibling.

◆ parent()

template<class Impl>
Node pixie::TreeBase< Impl >::parent ( const Node & node) const
inline

Return the parent of node.

Parameters
nodeValid node handle from this tree.
Returns
The parent handle, or the root itself when node is the root.

◆ root()

template<class Impl>
Node pixie::TreeBase< Impl >::root ( ) const
inline

Return the root node.

Returns
Handle identifying the root.

◆ size()

template<class Impl>
std::size_t pixie::TreeBase< Impl >::size ( ) const
inline

Return the number of nodes.

Returns
Number of nodes in the tree.

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