typedef struct queue {
int front;
int rear;
Data arr[SIZE];
}Queue;
void QueueInit(Queue* pq) {
pq->front = pq->rear = 0;
}
int QISEmpty(Queue* pq) {
pq->front == pq->rear ? 1 : 0;
}
int NextPosIdx(int pos) {
if (pos == SIZE - 1) return 0;
else return pos + 1;
}
void Enqueue(Queue* pq,Data data) {
if (NextPosIdx(pq->rear) == pq->front) {
printf("FULL BIN");
}
pq->rear = NextPosIdx(pq->rear);
pq->arr[pq->rear] = data;
}
Data Dequeue(Queue* pq) {
if (QISEmpty(pq))
{
printf("EMPTY");
}
pq->front = NextPosIdx(pq->front);
return pq->arr[pq->front];
}
Data QPeek(Queue* pq) {
if (QISEmpty(pq)) {
printf("EMPTY");
}
return pq->arr[pq->front];
}