本文整理汇总了C++中tree::createRootNode方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::createRootNode方法的具体用法?C++ tree::createRootNode怎么用?C++ tree::createRootNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::createRootNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cutTreeToTwoSpecial
// pre-request:
// the intermediateNode is the root.
// and it has two sons.
// resultT1PTR & resultT2PTR are empty trees (root=NULL);
void cutTreeToTwoSpecial(const tree& source, tree::nodeP intermediateNode,
tree &resultT1PTR, tree &resultT2PTR) {
// make sure that you got two empty trees:
if (resultT1PTR.getRoot() != NULL)
errorMsg::reportError("got a non empty tree1 in function cutTreeToTwoSpecial");
else if (resultT2PTR.getRoot() != NULL)
errorMsg::reportError("got a non empty tree2 in function cutTreeToTwoSpecial");
// make sure the the intermediateNode is really an intermediate Node;
if ((intermediateNode->getNumberOfSons() !=2 ) || (source.getRoot() != intermediateNode)) {
errorMsg::reportError("intermediateNode in function cutTreeToTwoSpecial, is not a real intermediate node ");
}
resultT1PTR.createRootNode();
resultT1PTR.getRoot()->setName(intermediateNode->name());
resultT2PTR.createRootNode();
resultT2PTR.getRoot()->setName(intermediateNode->name());
resultT1PTR.recursiveBuildTree(resultT1PTR.getRoot(),intermediateNode->getSon(0));
resultT2PTR.recursiveBuildTree(resultT2PTR.getRoot(),intermediateNode->getSon(1));
}