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); }
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); }