int main(int, char* [])
{
typedef int NodeType;
TreeType::Pointer tree = TreeType::New();
tree->SetRoot(0);
tree->Add(1,0);
tree->Add(2,0);
tree->Add(3,0);
tree->Add(4,2);
tree->Add(5,2);
tree->Add(6,5);
tree->Add(7,1);
std::cout << "LevelOrderTreeIterator:" << std::endl;
while(!levelIt.IsAtEnd())
{
std::cout << levelIt.Get()
<< " ("<< levelIt.GetLevel()
<< ")" << std::endl;
++levelIt;
}
std::cout << std::endl;
levelIt.GoToBegin();
levelIt.IsLeaf();
levelIt.IsRoot();
levelIt.HasParent();
levelIt.CountChildren();
std::cout << "ChildTreeIterator:" << std::endl;
{
std::cout << childIt.
Get() << std::endl;
++childIt;
}
std::cout << std::endl;
{
std::cout << "[FAILURE]" << std::endl;
return EXIT_FAILURE;
}
delete childItClone;
std::cout << "LeafTreeIterator:" << std::endl;
{
std::cout << leafIt.
Get() << std::endl;
++leafIt;
}
std::cout << std::endl;
std::cout << "InOrderTreeIterator:" << std::endl;
{
std::cout << InOrderIt.
Get() << std::endl;
++InOrderIt;
}
std::cout << std::endl;
std::cout << "PreOrderTreeIterator:" << std::endl;
{
std::cout << PreOrderIt.
Get() << std::endl;
++PreOrderIt;
}
std::cout << std::endl;
std::cout << "PostOrderTreeIterator:" << std::endl;
{
std::cout << PostOrderIt.
Get() << std::endl;
++PostOrderIt;
}
std::cout << std::endl;
std::cout << "RootTreeIterator:" << std::endl;
while(!RootIt.IsAtEnd())
{
std::cout << RootIt.Get() << std::endl;
++RootIt;
}
std::cout << std::endl;
tree->Clear();
IteratorCloneType aClone = anIterator;
return EXIT_SUCCESS;
}