Ejemplo n.º 1
0
void Node::DeleteSingleChildDescendants()
{
    TreeIterator* it = this->GetPostOrderIterator();

    Node* n = it->next();
    while (n)
    {
        if (n->GetNbChildren() == 1)
        {
            n = it->DeleteCurrent();
        }
        else
        {
            n = it->next();
        }
    }
    this->CloseIterator(it);
}
Ejemplo n.º 2
0
void Node::Restrict(bool (*fncDelete)(Node*, void*), void* arg)
{
    TreeIterator* it = this->GetPostOrderIterator();

    Node* n = it->next();
    while (n)
    {
        bool ok = (*fncDelete)(n, arg);

        if (!ok)
        {
            n = it->DeleteCurrent();
        }
        else
        {
            n = it->next();
        }
    }

    this->CloseIterator(it);

}