本文整理汇总了C++中AvlTree::Search方法的典型用法代码示例。如果您正苦于以下问题:C++ AvlTree::Search方法的具体用法?C++ AvlTree::Search怎么用?C++ AvlTree::Search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvlTree
的用法示例。
在下文中一共展示了AvlTree::Search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 */