ADD: return the root of the tree
This commit is contained in:
parent
b7b350a9e1
commit
ef31885f61
@ -52,6 +52,22 @@ namespace Tree
|
||||
std::list<std::shared_ptr<Tree::BaseNode>> children;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief get the root of the tree
|
||||
*
|
||||
*/
|
||||
std::shared_ptr<Tree::BaseNode> getRoot()
|
||||
{
|
||||
if (parent==nullptr)
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
return parent->getRoot();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief print the tree starting with the current node to stdout
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user