Advertisement
Guest User

Untitled

a guest
May 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #define MAIN_FILE
  2.  
  3. #include <iostream>
  4.  
  5. #include "RandomGenerator.h"
  6. #include "HeapQueue.h"
  7. #include "TournamentQueue.h"
  8. #include "BubbleQueue.h"
  9. #include "SelectionQueue.h"
  10.  
  11. #include "SimpleObject.h"
  12.  
  13.  
  14.  
  15. int main (int argc, char * const argv[]) {
  16.  
  17. RandomGenerator gen(277071); // tu nalezy wstawic numer indeksu
  18.  
  19.  
  20.  
  21. // Wybor implementacji kolejki:
  22.  
  23.  
  24. SelectionQueueLazy<SimpleObject<int> > theQueue;
  25.  
  26. // Proste, "silowe" testowanie kolejki
  27.  
  28. SimpleObject<int> a = SimpleObject<int>(8);
  29.  
  30. int licznoscxd[17] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 50, 75, 100, 125, 150, 175, 200 };
  31.  
  32. for (int i = 0; i < 17; i++) {
  33. std::cout << "Ilosc elementow: " << licznoscxd[i] << std::endl;
  34. for (int j = 0; j < licznoscxd[i]; j++) {
  35. a.setValue(gen.getRandom(1, 20));
  36. theQueue.put(a);
  37. }
  38. std::cout << "Comparisons: " << SimpleObject<int>::getComparisons() << "\n";
  39. std::cout << "Copyings: " << SimpleObject<int>::getCopyings() << "\n";
  40. try {
  41. std::cout << "get: " << theQueue.get().getValue() << "\n";
  42. }
  43. catch (QueueException& exc) {
  44. std::cout << "get: empty\n";
  45. }
  46. std::cout << "Comparisons: " << SimpleObject<int>::getComparisons() << "\n";
  47. std::cout << "Copyings: " << SimpleObject<int>::getCopyings() << "\n";
  48. std::cout << std::endl;
  49. }
  50.  
  51. system("pause");
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement