本文整理汇总了C++中tree::createNode方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::createNode方法的具体用法?C++ tree::createNode怎么用?C++ tree::createNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::createNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitSonsFromNode
void splitSonsFromNode(tree & et, tree::nodeP fatherNode, vector<tree::nodeP> & son2split)
{
for (int k=0; k < son2split.size(); ++k) {
if (son2split[k]->father() != fatherNode )
errorMsg::reportError(" error in function bootstrap::splitSonsFromNode - nodes don't have the same father");
}
// if the split allready exists, we do not need to do anything.
if (son2split.size()==fatherNode->getNumberOfSons() // the branch above us is the required split
|| son2split.size() <=1 // the branch below us is it
|| (fatherNode->father()==NULL && son2split.size()==fatherNode->getNumberOfSons()-1)
// the branch above us is the required split
)
return;
tree::nodeP theNewNode = et.createNode(fatherNode,et.getNodesNum());
theNewNode->setName("N"+int2string(theNewNode->id()));
for (int i=0; i < son2split.size(); ++i) {
son2split[i]->setFather(theNewNode);
theNewNode->setSon(son2split[i]);
// remove from son list of father node.
fatherNode->removeSon(son2split[i]);
}
}