Advertisement
jtentor

DemoQueue3 - DemoQueue3.cpp

May 17th, 2020
573
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #include <iostream>
  6. #include "specialqueue.h"
  7. #include <stdlib.h>
  8. #include <time.h>
  9.  
  10. int main() {
  11.     std::cout << "Demo Queue - versión genérica - Caso Ejemplo b)" << std::endl;
  12.     specialqueue<int> queue1 = specialqueue<int>(10);
  13.  
  14.     std::srand((unsigned int)time(NULL));
  15.  
  16.     int number;
  17.     std::cout << "Enqueuing..." << std::endl;
  18.     for (int c =0 ; c < 10; ++c) {
  19.         queue1.push(number = std::rand() % 10);
  20.         std::cout << number << " ";
  21.     }
  22.     std::cout << std::endl;
  23.  
  24.     std::cout << "Joining with same queue..." << std::endl;
  25.     specialqueue<int> queue2 = queue1.join(queue1);
  26.  
  27.     std::cout << "Dequeuing..." << std::endl;
  28.     while (queue1.size() > 0) {
  29.         std::cout << queue1.front() << " ";
  30.         queue1.pop();
  31.     }
  32.     std::cout << std::endl;
  33.  
  34.     std::cout << "Dequeuing joined queue..." << std::endl;
  35.     while (queue2.size() > 0) {
  36.         std::cout << queue2.front() << " ";
  37.         queue2.pop();
  38.     }
  39.     std::cout << std::endl;
  40.  
  41.     return 0;
  42. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement