当前位置: 首页>>代码示例>>C++>>正文


C++ AvlTree::inOrder方法代码示例

本文整理汇总了C++中AvlTree::inOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ AvlTree::inOrder方法的具体用法?C++ AvlTree::inOrder怎么用?C++ AvlTree::inOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AvlTree的用法示例。


在下文中一共展示了AvlTree::inOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){
	AvlTree t;
	t.insert(1);
	t.insert(2);
	t.insert(3);
	t.insert(4);
	t.insert(5);
	preOrder(t.getRoot());
	std::cout << std::endl;
	t.preOrder();
	inOrder(t.getRoot());
	std::cout << std::endl;
	t.inOrder();
	postOrder(t.getRoot());
	std::cout << std::endl;
	t.postOrder();
	std::cout << "Height:" << t.getHeight() << std::endl;
	AvlTree t1(t);
	std::cout << "t1 Height:" << t1.getHeight() << std::endl;
	AvlTree t2;
	t2 = t;
	std::cout << "t2 Height:" << t2.getHeight() << std::endl;
	t.insert(9);
	t.inOrder();
	t1.inOrder();
	t2.inOrder();
	return 0;
}
开发者ID:guhaibin1847,项目名称:data-structures-and-algorithm,代码行数:28,代码来源:main.cpp

示例2: value

main()
{
      
    AvlTree tree;
    Comparable * found = NULL;
    Comparable value(10);
    vector< Comparable > values;
    int  i;
    int size;
	int count;
	int preSize;
	int inSize;
	long inOrder[100];
	long toPayam2[100];
	long preOrder[100];
    for(i=0;i<10;i++) {
                      Comparable myComp(i);
                      values.push_back( myComp);
                      }
   // for (i = 0 ; i <10;i++){// NUM_ELEMENTS(TestVals) ; i++)  {
      // cout << "+++ inserting key #" << i+1<<endl ;//<< ": " << TestVals[i] << endl;
      for(i=0;i<10;i++){
                        
                         found = tree.Insert(&(values[i]));//&TestVals[i]);
                         
                         if (found) 
                         cout << "\t(already in tree)\n";
       }
       
        long * toPayam= tree.bsf(size);
		tree.postOrder(count,toPayam2);
		tree.preOrder(preSize,preOrder);
		tree.inOrder(inSize,inOrder);
		
		
        cout<<"sldfjsldf"<<endl;
        for(i=0;i<inSize;i++)  cout<<inOrder[i]<<endl;
       //VerifyTree(tree);
   // }/* for */

   // for (i = 0 ; i < NUM_ELEMENTS(TestVals) ; i++)  {
     //  cout << "+++ searching for key #" << i+1 << ": " << TestVals[i] << endl;
       found = tree.Search(1);
       if (! found) {
          cout << "\t(not found in tree)\n";
       }
       else cout<<" foung";
      /* VerifyTree(tree);
    }

    for (i = 0 ; i < NUM_ELEMENTS(DelVals) ; i++)  {
       cout << "+++ deleting key #" << i+1 << ": " << DelVals[i] << endl;
       found = tree.Delete(DelVals[i]);
       if (! found) {
          cout << "\t(not found in tree)\n";
       }
       VerifyTree(tree);
    } 

    cout << endl << "Deallocating tree ..." << endl;
    while (! tree.IsEmpty()) {
       found = tree.Delete(0, MAX_CMP);
       if (! found) {
          cout << "+++ max element not found in tree +++\n";
       } else {
          cout << "+++ deleted max element " << found->Key() << " +++\n";
       }
       delete found;
       VerifyTree(tree);
    }*/
    cout << "DONE!" << endl;
    cin>>i;
    return  0;
}/* main */
开发者ID:payamohajeri,项目名称:DS,代码行数:74,代码来源:AvlTest.cpp


注:本文中的AvlTree::inOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。