The following pseudocode shows the enqueue and dequeue operations of a circular queue that has been implemented with a zero based array.
enqueue
Procedure Enqueue IF iNumberInQueue = 6 THEN OUTPUT "Queue is full" ELSE IF iRear = 6 THEN iRear = 0 ELSE iRear = iRear + 1 END IF ArrayQueue(iRear) = new data item iNumberInQueue = iNumberInQueue + 1 END IF End Procedure
dequeue
Procedure Dequeue IF iNumberInQueue = 0 THEN OUTPUT "Queue is empty" ELSE copy item = ArrayQueue(iFront) iNumberInQueue = iNumberInQueue - 1 IF iFront = 6 THEN iFront = 0 ELSE iFront = iFront + 1 END IF END IF End Procedure