/* queue.c++ implementation of int queue */ #include "queue1b.h" queue::queue() { front = rear = count = 0; } int queue::isFullQ(){ return count == MAX; } int queue::isEmptyQ(){ return count == 0; } int queue::addQ(int n){ int temp, i; if(isFullQ()) return ERROR; rear = (rear + 1) % MAX; data[rear] = n; // count = count+1; *c0P=true; *turnP=1; while(*c1P && *turnP == 1); temp = count; for(i=1; i<= 100000; ++i); // Delay temp = temp+1; count = temp; *c0P=false; return OK; } int queue::frontQ(int &v){ if(isEmptyQ()) return ERROR; v = data[(front+1)%MAX] ; return OK; } int queue::deleteQ(){ int temp, i; if(isEmptyQ()) return ERROR; front = (front+1)%MAX ; // count = count - 1; *c1P=true; *turnP=0; while(*c0P && *turnP == 0); temp = count; for(i=1; i<= 100000; ++i); // Delay temp = temp-1; count = temp; *c1P=false; return OK; }