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


C++ PriorityQueue::printQueue方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
    cout<<"***********************************\nTesting Priority Linked List\n";

    P_LinkedList<int> pll;

    for (int i = 0; i < 20; ++i) {
        pll.append(i+1);
    }

    cout<<"Outputting list of size: "<<pll.size()<<endl;
    pll.printList();
    cout<<"\n\n";

    cout<<"Outputting peekMax()\n";
    cout<<pll.peekMax()<<endl;
    cout<<"Outputting popMax()\n";
    cout<<pll.popMax()<<endl;
     cout<<"Outputting list of size: "<<pll.size()<<endl;
     pll.printList();
     cout<<"\n\n";

     cout<<"Outputting peekMin()\n";
     cout<<pll.peekMin()<<endl;
     cout<<"Outputting popMin()\n";
     cout<<pll.popMin()<<endl;
     cout<<"Outputting list of size: "<<pll.size()<<endl;
     pll.printList();
     cout<<"\n\n";



    cout<<"*****************************************\nTesting Priority Queue\n";

    PriorityQueue<int> pq;

    for (int i = 0; i < 20; ++i) {
        pq.push((rand()%30)+1);
    }

    cout<<"Outputting list of size: "<<pq.size()<<endl;
    pq.printQueue();
    cout<<"\n\n";

    cout<<"OutPutting front()\n";
    cout<< pq.front()   <<endl;
    cout<<"OutPutting back()\n";
    cout<< pq.back()   <<endl;
    cout<<"\n\n";


    cout<<"pop()ing 10 elements\n";
    for (int i = 0; i < 10; ++i) {
        cout<<pq.pop()<<endl;
    }
    cout<<"\n\n";

    cout<<"Outputting list of size: "<<pq.size()<<endl;
    pq.printQueue();
    cout<<"\n\n";

    cout<<"Instanciating descending object\n";
    PriorityQueue<int> pqd(SortOrder::DEC);

    for (int i = 0; i < 10; ++i) {
        pqd.push((rand()%15)+1);
    }
    cout<<"Outputting list of size: "<<pqd.size()<<endl;
    pqd.printQueue();
    cout<<"\n\n";

    cout<<"OutPutting front()\n";
    cout<< pqd.front()   <<endl;
    cout<<"OutPutting back()\n";
    cout<< pqd.back()   <<endl;
    cout<<"\n\n";


    cout<<"pop()ing 5 elements\n";
    for (int i = 0; i < 5; ++i) {
        cout<<pqd.pop()<<endl;
    }
    cout<<"\n\n";

    cout<<"Outputting list of size: "<<pqd.size()<<endl;
    pqd.printQueue();
    cout<<"\n\n";


    cout<<"*************************************\nTesting Sorted Linked List\n";
    S_LinkedList<int> sll(SortOrder::ASC);

    for (int i = 0; i < 100; ++i) {
        sll.push((rand()%50)+1);
    }

    cout<<"Outputting lis of size: "<<sll.size()<<endl;
    sll.printList();
    cout<<"\n\n";

    return 0;
}
开发者ID:bwarfield,项目名称:WarfieldBrian_CIS17C_48942,代码行数:101,代码来源:main.cpp


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