//--------------------------------------------------- // Edit: 27 Jan 2003 DLF namespace std; for g++ v3.2 // 10 Mar 2004 DLF remove dsexceptions.h and just // make exception classes local but guarded //--------------------------------------------------- /* Queue.H CMSC-341 Spring 2004 Project3 Spencer Shimko, Section 001, sshimko1 Unmodified Weiss's code I have read and I understand the course policy on cheating. By submitting the following program, I am stating that the program was produced by my individual effort. */ #ifndef _QUEUEAR_H #define _QUEUEAR_H #include using namespace std; // Queue class -- array implementation // // CONSTRUCTION: with or without a capacity; default is 10 // // ******************PUBLIC OPERATIONS********************* // void enqueue( x ) --> Insert x // Object dequeue( ) --> Return and remove least // recently inserted item // Object getFront( ) --> Return least recently inserted item // bool isEmpty( ) --> Return true if empty; else false // bool isFull( ) --> Return true if full; else false // void makeEmpty( ) --> Remove all items // ******************ERRORS******************************** // Overflow and Underflow thrown as needed #ifndef WEISS_EXCEPTIONS #define WEISS_EXCEPTIONS class Underflow { }; class Overflow { }; class OutOfMemory { }; class BadIterator { }; #endif template class Queue { public: explicit Queue( int capacity = 10 ); bool isEmpty( ) const; bool isFull( ) const; const Object & getFront( ) const; void makeEmpty( ); Object dequeue( ); void enqueue( const Object & x ); private: vector theArray; int currentSize; int front; int back; void increment( int & x ); }; #include "Queue.C" #endif