ADD: method to search for all nodes with a given base
This commit is contained in:
parent
cf58516daf
commit
6d55169a5f
@ -225,12 +225,25 @@ namespace Tree
|
|||||||
/**
|
/**
|
||||||
* @brief finds all nodes of a given base
|
* @brief finds all nodes of a given base
|
||||||
*
|
*
|
||||||
* @param base - the base type of the node as a string
|
* @param b - the base type of the node as a string
|
||||||
* @param c - a container for holding all found nodes, has to be holding objects of type std::shared_ptr<Tree::BaseNode>
|
* @param c - a container for holding all found nodes, has to be holding objects of type std::shared_ptr<Tree::BaseNode>
|
||||||
*/
|
*/
|
||||||
template <typename Container>
|
template <class Container>
|
||||||
void findAllBase(const std::string &base, Container &c);
|
void findAllBase(const std::string &b, Container &c)
|
||||||
|
{
|
||||||
|
std::list<std::shared_ptr<Tree::BaseNode>>::iterator it;
|
||||||
|
|
||||||
|
if (base() == b)
|
||||||
|
{
|
||||||
|
c.push_back(shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(it = children.begin(); it != children.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->findAllBase(b,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief checks if the given node is a direct child of this node
|
* @brief checks if the given node is a direct child of this node
|
||||||
|
Loading…
Reference in New Issue
Block a user