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


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

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


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

示例1: main

int  main()
   {
    PriorityQueue<DataType> testPQA;
    PriorityQueue<DataType> testPQB;
    PriorityQueue<DataType> testPQC;
    char cmdChar;
    DataType dataItem;
    int qPriority;
    char qProcess[ SMALL_STR_LEN ];
    bool dataChanged;

    ShowMenu();

    do
       {
        dataChanged = false;

        cout << endl << "Command: ";                  // Read command
        
        cmdChar = GetCommandInput( qProcess, qPriority );

        switch ( cmdChar )
           {
            case 'c': case 'C':  // clear priority queue

               while( !testPQA.isEmpty() )
                  {
                   testPQA.dequeue( dataItem );
                  }

               if( VERBOSE )
                  {
                   cout << "  Priority Queue has been cleared " << endl;
                  }

               dataChanged = true;

               break;

            case 'd': case 'D':  // dequeue one data item

               testPQA.dequeue( dataItem );

               if( VERBOSE )
                  {
                   cout << "  Process: " << dataItem.process
                        << " has been dequeued with a priority of "
                        << dataItem.priority << PERIOD << endl;
                  }

               dataChanged = true;

               break;

            case 'e': case 'E':  // enqueue

               testPQA.enqueue( qPriority, qProcess );

               if( VERBOSE )
                  {
                   cout << "  Process: " << qProcess
                        << " has been enqueued with a priority of "
                        << qPriority << PERIOD << endl;
                  }

               dataChanged = true;

               break;

            case 'h': case 'H':  // help request

               ShowMenu();

               break;

            case 'p': case 'P':  // peek at next item

               testPQA.peekAtFront( dataItem );

               if( VERBOSE )
                  {
                    cout << "  Process: " << dataItem.process
                         << " with priority: " << dataItem.priority
                         << " found at front of queue." << endl;
                  }
               break;

            case 'q': case 'Q':  // quit the test program

               if( VERBOSE )
                  {
                   cout << "  End Program Requested" << endl;
                  }

               cout << endl;

               break;

            case 'x': case 'X':  // create copy constructor PQ

//.........这里部分代码省略.........
开发者ID:tahoelizard,项目名称:CS302,代码行数:101,代码来源:PA03.cpp


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