ADD: return the root of the tree

This commit is contained in:
Dominik Meyer 2019-06-04 10:55:28 +02:00
parent b7b350a9e1
commit ef31885f61
1 changed files with 16 additions and 0 deletions

View File

@ -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
*