// IntQueue.cpp // Integer queue class member functions // CS210 - S'03 - 3/6/03 - Ray S. Babcock // #include using namespace std; #include "IntQueue.h" IntQueue::IntQueue(int qs) : qsize(qs) { front = NULL; rear = NULL; items = 0; } IntQueue::~IntQueue() { Node * temp; while(front != NULL) { temp = front; front = front->next; delete temp; } } bool IntQueue::isEmpty() const { return items == 0; } bool IntQueue::isFull() const { return items == qsize; } int IntQueue::queueCount() const { return items; } bool IntQueue::enqueue(const int & value) { if(isFull()) return false; Node * add = new Node; if(add == NULL) return false; add->value = value; add->next = NULL; items++; if(front == NULL) front = add; else rear->next = add; rear = add; return true; } bool IntQueue::dequeue(int & value) { if(front == NULL) return false; value = front->value; items--; Node * temp = front; front = front->next; delete temp; if(items == 0) rear = NULL; return true; }