Advertisement
Leedwon

Untitled

May 1st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // kolejka
  2.  
  3.  
  4. #ifndef QUEUE1_H_
  5. #define QUEUE1_H_
  6.  
  7. class Customer
  8. {
  9. private:
  10. long arrive; // czas dolaczenia klienta do kolejki
  11. int processtime; // czas obslugi klienta
  12. public:
  13. Customer() { arrive = processtime = 0; }
  14. void set(long when); // ustawia losowo processtime
  15. long when() const { return arrive; } // kiedy dolaczyl do kolejki
  16. int ptime() const { return processtime; } // ile czasu spedzi przy bankomacie
  17. };
  18.  
  19. typedef Customer Item;
  20. class Queue
  21. {
  22. private:
  23. struct Node
  24. {
  25. Item item;
  26. struct Node * next;
  27. };
  28. Node * front;
  29. Node * rear;
  30. int items;
  31. enum { Q_SIZE = 10 };
  32. const int qsize;
  33. public:
  34. Queue(int qs = Q_SIZE);
  35. ~Queue();
  36. Item & firstin() { if (front != nullptr) return front->item; }
  37. bool isempty();
  38. bool isfull();
  39. int queuecount() const;
  40. bool enqueue(const Item & item);
  41. bool dequeue(Item & item);
  42. friend bool operator>(const Queue & q1, const Queue & q2);
  43. friend bool operator<(const Queue & q1, const Queue & q2);
  44. };
  45.  
  46. #endif // !QUEUE_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement