weiss.nonstandard
Class ListQueue

java.lang.Object
  |
  +--weiss.nonstandard.ListQueue
All Implemented Interfaces:
Queue

public class ListQueue
extends java.lang.Object
implements Queue

List-based implementation of the queue.


Constructor Summary
ListQueue()
          Construct the queue.
 
Method Summary
 java.lang.Object dequeue()
          Return and remove the least recently inserted item from the queue.
 void enqueue(java.lang.Object x)
          Insert a new item into the queue.
 java.lang.Object 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

ListQueue

public ListQueue()
Construct the queue.
Method Detail

isEmpty

public boolean isEmpty()
Test if the queue is logically empty.
Specified by:
isEmpty in interface Queue
Returns:
true if empty, false otherwise.

enqueue

public void enqueue(java.lang.Object x)
Insert a new item into the queue.
Specified by:
enqueue in interface Queue
Parameters:
x - the item to insert.

dequeue

public java.lang.Object dequeue()
Return and remove the least recently inserted item from the queue.
Specified by:
dequeue in interface Queue
Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

getFront

public java.lang.Object getFront()
Get the least recently inserted item in the queue. Does not alter the queue.
Specified by:
getFront in interface Queue
Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

makeEmpty

public void makeEmpty()
Make the queue logically empty.
Specified by:
makeEmpty in interface Queue