Advertisement
Phr0zen_Penguin

abq.cpp - VTC C++ Array-Based Queue Example

Apr 29th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. /**
  2.  * [abq.cpp]
  3.  * Array-based queue example.
  4.  *
  5.  * compile with:
  6.  * g++ -m32 -static-libgcc -o abq abq.cpp ArrayBasedQueue.cpp
  7.  */
  8.  
  9. #include "ArrayBasedQueue.h"
  10.  
  11. int main(void)
  12. {
  13.     /**
  14.      * Array-Based Queue OBJECT CREATION:
  15.      */
  16.     ArrayBasedQueue *abq = new ArrayBasedQueue(2);
  17.  
  18.  
  19.     /**
  20.      * Array-Based Queue STATUS CHECK:
  21.      */
  22.     std::cout << "Is Empty? " << ((abq->IsEmpty()) ? "yes" : "no") << std::endl << std::endl;
  23.  
  24.  
  25.         /**
  26.          * Array-Based Queue ITEM ENQUEUE:
  27.          */
  28.         while(!abq->IsFull())
  29.             abq->Enqueue(2);
  30.  
  31.  
  32.     /**
  33.      * Array-Based Queue STATUS CHECK:
  34.      */
  35.     std::cout << "Is Empty? " << ((abq->IsEmpty()) ? "yes" : "no") << std::endl;
  36.     std::cout << "Is Full? " << ((abq->IsFull()) ? "yes" : "no") << std::endl << std::endl;
  37.  
  38.  
  39.     /**
  40.      * Array-Based Queue ITEM DEQUEUE:
  41.      */
  42.     float   item;
  43.  
  44.     abq->Dequeue(item);
  45.  
  46.  
  47.         /**
  48.          * Array-Based Queue ITEM ENQUEUE:
  49.          */
  50.         if(!abq->IsFull())
  51.             abq->Enqueue(4);
  52.  
  53.  
  54.         /**
  55.          * Array-Based Queue ITEM DEQUEUE/OUTPUT:
  56.          */
  57.         while(!abq->IsEmpty())
  58.         {
  59.             abq->Dequeue(item);
  60.  
  61.             std::cout << item << std::endl;
  62.         }
  63.  
  64.  
  65.     /**
  66.      * Array-Based Queue OBJECT DELETION:
  67.      */
  68.     delete abq;
  69.  
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement