weiss.nonstandard
Class ArrayQueue<AnyType>

java.lang.Object
  extended by weiss.nonstandard.ArrayQueue<AnyType>
All Implemented Interfaces:
Queue<AnyType>

public class ArrayQueue<AnyType>
extends java.lang.Object
implements Queue<AnyType>

Array-based implementation of the queue.


Constructor Summary
ArrayQueue()
          Construct the queue.
 
Method Summary
 AnyType dequeue()
          Return and remove the least recently inserted item from the queue.
 void enqueue(AnyType x)
          Insert a new item into the queue.
 AnyType getFront()
          Get the least recently inserted item in the queue.
 boolean isEmpty()
          Test if the queue is logically empty.
 void makeEmpty()
          Make the queue logically empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayQueue

public ArrayQueue()
Construct the queue.

Method Detail

isEmpty

public boolean isEmpty()
Test if the queue is logically empty.

Specified by:
isEmpty in interface Queue<AnyType>
Returns:
true if empty, false otherwise.

makeEmpty

public void makeEmpty()
Make the queue logically empty.

Specified by:
makeEmpty in interface Queue<AnyType>

dequeue

public AnyType dequeue()
Return and remove the least recently inserted item from the queue.

Specified by:
dequeue in interface Queue<AnyType>
Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

getFront

public AnyType getFront()
Get the least recently inserted item in the queue. Does not alter the queue.

Specified by:
getFront in interface Queue<AnyType>
Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

enqueue

public void enqueue(AnyType x)
Insert a new item into the queue.

Specified by:
enqueue in interface Queue<AnyType>
Parameters:
x - the item to insert.