本文整理汇总了C++中BinaryTree::GetRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryTree::GetRoot方法的具体用法?C++ BinaryTree::GetRoot怎么用?C++ BinaryTree::GetRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree::GetRoot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* virtual */ void FsLazyWindowApplication::Interval(void)
{
int lb,mb,rb,mx,my;
FsGetMouseEvent(lb,mb,rb,mx,my);
mouseOn=PickedNode(mx,my);
auto key=FsInkey();
if(FSKEY_ESC==key)
{
SetMustTerminate(true);
}
if(FSKEY_D==key && nullptr!=mouseOn)
{
btree.Delete(mouseOn);
VerifyTree();
}
if(FSKEY_L==key && nullptr!=mouseOn)
{
btree.RotateLeft(mouseOn);
VerifyTree();
}
if(FSKEY_B==key)
{
BreadthFirstTraversal(btree.GetRoot());
}
needRedraw=true;
}
示例2: main
int main()
{
int foo[] = {1, 2, 3, 4, 5, 6, 7, 8};
int size = sizeof (foo) / sizeof (int);
std::vector<int> vec (foo, foo + size);
BinaryTree bar (vec);
Node* root = (Node*) bar.GetRoot();
PrintTreeLevelOrderI (root);
printf ("\n");
printf ("is valid tree %d\n", isValidTree (root) );
}
示例3: main
/************************************* MAIN FUNCTION *************************************/
int main()
{
//#7 Create a binary tree call b and insert nodes m,a,q
//Create a binary tree called 'b'
BinaryTree * b = new BinaryTree();
char m = 'm', a = 'a', q = 'q';
//insertNodes 'm','a','q' in this specific order
b->InsertNode(m);
b->InsertNode(a);
b->InsertNode(q);
//#8 call recurisve and non recursive functions of order types
//call both postorderR and postorder
std::cout << "Postorder: ";
b->Postorder();
std::cout << std::endl;
std::cout << "PostorderR: ";
b->PostorderR(b->GetRoot());
std::cout << std::endl;
//call both inorderR and inorder
std::cout << "Inorder: ";
b->Inorder();
std::cout << std::endl;
std::cout << "InorderR: ";
b->InorderR(b->GetRoot());
std::cout << std::endl;
//call both preorderR and preorder
std::cout << "Preorder: ";
b->Preorder();
std::cout << std::endl;
std::cout << "PreorderR: ";
b->PreorderR(b->GetRoot());
std::cout << std::endl;
std::system("pause");
return 1;
}
示例4: VerifyTree
void FsLazyWindowApplication::VerifyTree(void) const
{
std::vector <int> v;
MakeLinear(v,btree.GetRoot());
for(int i=0; i<v.size(); ++i)
{
printf(" %d",v[i]);
}
printf("\n");
for(int i=0; i+1<v.size(); ++i)
{
if(v[i]>v[i+1])
{
printf("Error! %d>%d\n",v[i],v[i+1]);
}
}
}
示例5: PickedNode
const BinaryTree <int,int>::Node *FsLazyWindowApplication::PickedNode(int mx,int my) const
{
int wid,hei;
FsGetWindowSize(wid,hei);
return PickedNode(btree.GetRoot(),mx,my,0,wid,40,40);
}
示例6: EGthanX
std::vector<int> EGthanX(const BinaryTree<int> & BST, const int x) {
std::vector<int> ret;
EGthanX_impl(BST.GetRoot(), x, ret);
return ret;
}