本文整理汇总了C++中BTreeNode::setLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ BTreeNode::setLeft方法的具体用法?C++ BTreeNode::setLeft怎么用?C++ BTreeNode::setLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTreeNode
的用法示例。
在下文中一共展示了BTreeNode::setLeft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileConditional
void Expression::compileConditional( const QString & expression, Code * ifCode, Code * elseCode )
{
if( expression.contains(QRegExp("=>|=<|=!")) )
{
mistake( Microbe::InvalidComparison, expression );
return;
}
if( expression.contains(QRegExp("[^=><!][=][^=]")))
{
mistake( Microbe::InvalidEquals );
return;
}
// Make a tree to put the expression in.
BTreeBase *tree = new BTreeBase();
BTreeNode *root = new BTreeNode();
// parse the expression into the tree
buildTree(expression,tree,root,0);
// Modify the tree so it is always at the top level of the form (kwoerpkwoep) == (qwopekqpowekp)
if ( root->childOp() != equals &&
root->childOp() != notequals &&
root->childOp() != gt &&
root->childOp() != lt &&
root->childOp() != ge &&
root->childOp() != le &&
root->childOp() != pin &&
root->childOp() != notpin &&
root->childOp() != read_keypad )
{
BTreeNode *newRoot = new BTreeNode();
BTreeNode *oneNode = new BTreeNode();
oneNode->setChildOp(noop);
oneNode->setType(number);
oneNode->setValue("1");
newRoot->setLeft(root);
newRoot->setRight(oneNode);
newRoot->setType(unset);
newRoot->setChildOp(ge);
tree->setRoot(newRoot);
root = newRoot;
}
// compile the tree into assembly code
tree->setRoot(root);
tree->pruneTree(tree->root(),true);
// We might have just a constant expression, in which case we can just always do if or else depending
// on whether it is true or false.
if( root->childOp() == noop )
{
if( root->value().toInt() == 0 )
m_pic->mergeCode( elseCode );
else
m_pic->mergeCode( ifCode );
return;
}
// traverse tree with argument conditionalRoot true
// so that 3 == x gets integrated with code for if, repeat until etc...
m_ifCode = ifCode;
m_elseCode = elseCode;
traverseTree(tree->root(),true);
// Note deleting the tree deletes all nodes, so the root
// doesn't need deleting separately.
delete tree;
}