本文整理汇总了C++中AVL::display方法的典型用法代码示例。如果您正苦于以下问题:C++ AVL::display方法的具体用法?C++ AVL::display怎么用?C++ AVL::display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AVL
的用法示例。
在下文中一共展示了AVL::display方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
int i, j, n;
double t;
AVL<int> tree;
if (argc > 3) return EXIT_FAILURE;
i = time(0);
if (argc == 1) n = 20;
else {
n = atoi(argv[1]);
if (argc == 3) i = atoi(argv[2]);
}
srand((unsigned int)i);
cout << "Size is " << n << endl;
cout << "Seed is " << i << endl;
cout << "Inserting..." << endl;
t = ((double)clock())/CLOCKS_PER_SEC;
for (i = 1 ; i <= n ; i++) {
j = rand()%n+1;
// cout << j << ' ';
tree.insert(j);
}
t = ((double)clock())/CLOCKS_PER_SEC-t;
cout << t << " secs" << endl;
// cout << "\nPrinting tree..." << endl;
// tree.print();
cout << "Size of tree is: " << tree.size() << endl;
ofstream out("avl.dot");
tree.display(out);
out.close();
system("dot avl.dot -Tpng -o avl.png");
cout << "Created tree image at avl.png!" << endl;
cout << "Extracting..." << endl;
t = ((double)clock())/CLOCKS_PER_SEC;
for (i = 1 ; i <= n ; i++) {
j = rand()%n+1;
// cout << j << ' ';
tree.extract(j);
}
t = ((double)clock())/CLOCKS_PER_SEC-t;
cout << t << " secs" << endl;
// cout << "\nPrinting tree..." << endl;
// tree.print();
cout << "Size of tree is: " << tree.size() << endl;
cout << "Clearing..." << endl;
t = ((double)clock())/CLOCKS_PER_SEC;
tree.clear();
t = ((double)clock())/CLOCKS_PER_SEC-t;
cout << t << " secs" << endl;
return EXIT_SUCCESS;
}