Code Fragment: Queue



/**
 * Interface for a queue: A collection of objects that are inserted
 * and removed according to the first-in first-out principle.
 */
template <typename Object>
class Queue {
public:
 /** 
  * Returns the number of objects in the queue.
  */
  int size() const;  
 /** 
  * Returns true if the queue is empty, false otherwise.
  */
  bool isEmpty() const; 
 /**
  * Returns the front object of the queue.
  * Throws QueueEmptyException if the queue is empty.
  */
  Object& front() throw(QueueEmptyException); 
 /** 
  * Inserts an object at the rear of the queue.
  */
  void enqueue (const Object& obj); 
 /** 
  * Remove and returns the object at the front of the queue.
  * Throws QueueEmptyException if the queue is empty.
  */
  Object dequeue() throw(QueueEmptyException); 
};