本文整理汇总了C++中TNode::getChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::getChild方法的具体用法?C++ TNode::getChild怎么用?C++ TNode::getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNode
的用法示例。
在下文中一共展示了TNode::getChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preorder_traversal
void KTREE::preorder_traversal()
{
TNode *tmp; //pre order
tmp=top;
if (top==0)
cout <<"empty tree !!!"<<endl;
else
{
cout <<tmp->getElement()<<" ";
for (int i=0;i<MAX;i++)
if (top->getChild(i)!=0)
preorder_traversal(top->getChild(i));
}
cout<<endl;
}
示例2: insert
void KTREE::insert (TNode* node,int ch)
{
TNode* tmp;
//insert to tree
point=top;
if (top==0)
{
top=new TNode();
top->setElement(node->getElement());
top->setParent(0);
for (int i=0;i<MAX;i++)
top->setChild(node->getChild(i),i);
point=top;
}
else
{
while (point!=0)
{
tmp=point;
point=point->getChild(ch);
}
point=tmp;
addLeaf(node,ch);
}
}
示例3: postorder_traversal
void KTREE::postorder_traversal()
{ //postorder
TNode *tmp;
tmp=top;
int i;
if (top==0)
cout <<"empty tree !!!"<<endl;
else
{
for (i=0;i<MAX;i++)
{
if (top->getChild(i)!=0)
postorder_traversal(top->getChild(i));
}
cout <<" "<<top->getElement();
}
cout<<endl;
}
示例4: converseAST
vector<std::shared_ptr<CFG>> NextExtractor::constructCFG()
{
int numOfProc = procTable->getSize();
for(int i =0; i < numOfProc; i++)
{
TNode* curTNode = this->procTable->getASTRootNode(i);
shared_ptr<GNode> curGNodeParent = std::make_shared<GNode>(0, "PROC_NODE"); //create a CFG ROOT node
nodeMap.insert(pair<int, shared_ptr<GNode>>(curGNodeParent->getStmtNum(), curGNodeParent));
shared_ptr<CFG> cfg = std::make_shared<CFG>(curGNodeParent); //create a CFG with procedure node as parameters
shared_ptr<stack<shared_ptr<GNode>>> level = std::make_shared<stack<shared_ptr<GNode>>>();
shared_ptr<GNode> lastNode = converseAST(cfg,curTNode->getChild(0),curGNodeParent,level); //conversing start with node below procedure
CFGTable.push_back(cfg);
}
return CFGTable;
}