Lab Assign 3
Lab Assign 3
private T[] queue; // circular array of queue entries and one unused location
private int frontIndex;
private int backIndex;
private static final int DEFAULT_INITIAL_CAPACITY = 50;
public ArrayQueue() {
this(DEFAULT_INITIAL_CAPACITY);
} // end default constructor
public T getFront(){
T front = null;
if (!isEmpty())
front = queue[frontIndex];
return front;
} // end getFront
public T dequeue() {
T front = null;
if (!isEmpty()) {
front = queue[frontIndex];
queue[frontIndex] = null;
frontIndex = (frontIndex + 1) % queue.length;
} // end if
return front;
} // end dequeue
frontIndex = 0;
backIndex = oldSize - 2;
} // end if
} // end ensureCapacity
} // end ArrayQueue