Advertisement
Guest User

queues

a guest
Aug 2nd, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1.     // Generic FIFO queue ----------------------------------------------------------
  2.  
  3.     template<typename T>
  4.     class queue {
  5.      public:
  6.       virtual ~queue() {}
  7.       virtual void enqueue(const T& t) = 0;
  8.       virtual void enqueue(T&& t) = 0;
  9.       virtual T dequeue() = 0;
  10.     };
  11.  
  12.     // Bounded queues --------------------------------------------------------------
  13.  
  14.     class upper_bounded_queue : public virtual queue {
  15.     public:
  16.       virtual bool full() = 0;
  17.     };
  18.  
  19.     class lower_bounded_queue : public virtual queue {
  20.     public:
  21.       virtual bool empty() = 0;
  22.     };
  23.  
  24.     class bounded_queue : public virtual upper_bounded_queue,
  25.                       public virtual lower_bounded_queue {}
  26.  
  27.     // Unbounded queues ------------------------------------------------------------
  28.  
  29.     class upper_unbounded_queue : public virtual upper_bounded_queue {
  30.     public:
  31.       virtual bool full() { return false; } final;
  32.     };
  33.  
  34.     class lower_unbounded_queue : public virtual lower_bounded_queue {
  35.     public:
  36.       virtual bool empty() { return false; } final;
  37.     };
  38.  
  39.     class unbounded_queue : public virtual bounded_queue,
  40.                         public virtual upper_bounded_queue,
  41.                         public virtual lower_bounded_queue {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement