本文整理汇总了C++中AvlTree::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ AvlTree::Insert方法的具体用法?C++ AvlTree::Insert怎么用?C++ AvlTree::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvlTree
的用法示例。
在下文中一共展示了AvlTree::Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
AvlTree tree = AvlTree();
tree.Insert(3);
tree.Insert(4);
tree.Insert(5);
tree.Insert(6);
tree.Insert(2);
tree.Print();
tree.Insert(1);
tree.Print();
tree.Insert(7);
tree.Print();
tree.Delete(4);
tree.Print();
tree.Delete(6);
tree.Print();
tree.Delete(7);
tree.Print();
}
示例2: main
int main(){
AvlTree<int> l;
for(int i = 1 ; i <= 15 ; i++){
l.Insert(i);
}
l.PrintTree();
while(true){
int toDelete;
cout<<"请输入要删除节点的值:"<<endl;
cin>>toDelete;
l.Delete(toDelete);
cout<<"删除后的树为:"<<endl;
l.PrintTree();
}
return 0;
system("PAUSE");
}
示例3: InsertTest
void InsertTest()
{
o.Insert(24);
o.Insert(13);
o.Insert(1);
o.Insert(29);
o.Insert(2);
o.Insert(3);
o.Insert(22);
o.Insert(26);
o.Insert(25);
o.Insert(12);
cout<<"TEST WSTAWIANIA ZOSTAL PRZEPROWADZONY\n\n\n";
}
示例4: 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 */