Please send questions to
st10@humboldt.edu .
//---------------------------------------------------------------------
// File: queue.h
// Name: Sharon M. Tuttle
// last modified: 4-01-05
//
// Class name: queue
//
// Description: a collection of items such that entries can be
// inserted at one end (called the rear) and removed at the
// other end (called the front).
// This version does NOT have a fixed capacity.
//
//---------------------------------------------------------------------
#ifndef QUEUE_H
#define QUEUE_H
#include <cstdlib> // provides NULL
#include "node.h"
using namespace std;
template <typename Item>
class queue
{
public:
/****************************************************/
/* TYPEDEFS and MEMBER CONSTANTS */
/****************************************************/
typedef Item value_type;
/*****************************************************/
/* CONSTRUCTORS and DESTRUCTORS */
/*****************************************************/
// postcondition: creates an empty queue instance
//
queue();
// copy constructor
//
queue(const queue& source);
// destructor
//
~queue( );
/*************************************************************/
/* ACCESSORS and other constant member functions (observers) */
/*************************************************************/
// postcondition: returns true if queue is empty, and
// returns false otherwise
//
bool is_empty( ) const;
// precondition: is_empty() == false
//
// postcondition: returns the value of the front item of the
// queue, BUT the queue is unchanged.
//
value_type get_front( ) const;
/*****************************************************/
/* MODIFIERS and other modifying member functions */
/*****************************************************/
// postcondition: a new copy of entry has been inserted
// at the rear of the queue
//
void enqueue(const value_type& entry);
// precondition: is_empty() == false
//
// postcondition: the front item of the queue has been
// removed and is returned
//
value_type dequeue( );
private:
/*****************************************************/
/* DATA FIELDS */
/*****************************************************/
node<Item>* front; // pointer to node containing front
// of queue
node<Item>* rear ; // pointer to node containing rear
// of queue
int used; // how many items are in the queue
};
#include "queue.template"
#endif