/************************************************************* * Queues are loaded from the rear and emptied from the * front. In this example with load a 5 item queue with 5 items * and then add one more item. The item first added is removed, * and everything else is moved up a notch. * * * Empty queue * N->N->N->N->N-> * * add the number 3 * 3->N->N->N->N-> * * add the number 7 * 7->3->N->N->N-> * * Full queue * 5->4->3->2->1-> * * add the number 8 * 8->5->4->3->2-> 1 goes in the garbage * * * **************************************************************/ public class BasicQueue { int maxSize; int queArray[]; int front; int rear; int nItems; public BasicQueue(int s) { maxSize = s; queArray = new int[maxSize]; front = 0; rear = -1; nItems = 0; } public void insert(int j) { if(rear == maxSize-1){ for(int i = 0; i