/* * queue.c++ implementation of int * queue * $ g++ -Wall -c queue.c++ */ #include "queue.h" queue::queue() { front = rear = 0; count = 0; } int queue::isFullQ(){ return count == MAX; } int queue::isEmptyQ(){ return count == 0; } int queue::addQ(int n){ if(isFullQ()) return ERROR; rear = (rear + 1) % MAX; data[rear] = n; count = count+1; return OK; } int queue::frontQ(int &v){ if(isEmptyQ()) return ERROR; v = data[(front+1)%MAX] ; return OK; } int queue::deleteQ(){ if(isEmptyQ()) return ERROR; front = (front+1)%MAX ; count = count - 1; return OK; }