Source of Listing13-1.h


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: // Listing 13-1.

  6: /** @file QueueInterface.h */
  7: #ifndef QUEUE_INTERFACE_
  8: #define QUEUE_INTERFACE_

 10: template<class ItemType>
 11: class QueueInterface
 12: {
 13: public:
 14:    /** Sees whether this queue is empty.
 15:     @return  True if the queue is empty, or false if not. */
 16:    virtual bool isEmpty() const = 0;
 17:    
 18:    /** Adds a new entry to the back of this queue.
 19:     @post  If the operation was successful, newEntry is at the
 20:        back of the queue.
 21:     @param newEntry  The object to be added as a new entry.
 22:     @return  True if the addition is successful or false if not. */
 23:    virtual bool enqueue(const ItemType& newEntry) = 0;
 24:    
 25:    /** Removes the front of this queue.
 26:     @post  If the operation was successful, the front of the queue
 27:        has been removed.
 28:     @return  True if the removal is successful or false if not. */
 29:    virtual bool dequeue() = 0;
 30:    
 31:    /** Returns the front of this queue.
 32:     @pre  The queue is not empty.
 33:     @post  The front of the queue has been returned, and the
 34:        queue is unchanged.
 35:     @return  The front of the queue. */
 36:    virtual ItemType peekFront() const = 0;
 37:    
 38:    /** Destroys this queue and frees its memory. */
 39:    virtual ~QueueInterface() { }
 40: }; // end QueueInterface
 41: #endif