Class SLQueue

java.lang.Object
  |
  +--SLQueue
All Implemented Interfaces:
Queue

class SLQueue
extends java.lang.Object
implements Queue

SLQueue is an implementation of Queue, a repository for Objects. Objects are inserted using enqueue and removed using dequeue. Objects are removed in the same order in which they are inserted. A singly-linked list is used to maintain the Queue.


Nested Class Summary
(package private)  class SLQueue.Cell
          A Cell stores one Object in the Queue and points to the next newer Object if any.
 
Field Summary
protected  SLQueue.Cell head
          the Cell containing the next Object to be removed
protected  SLQueue.Cell tail
          the Cell containing the most recent Object inserted
 
Constructor Summary
SLQueue()
          Construct an empty SLQueue.
 
Method Summary
 java.lang.Object dequeue()
          Remove an Object from the queue.
 void enqueue(java.lang.Object item)
          Insert an Object in the queue.
 boolean isEmpty()
          Indicate whether or not the Queue is empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

protected SLQueue.Cell head
the Cell containing the next Object to be removed


tail

protected SLQueue.Cell tail
the Cell containing the most recent Object inserted

Constructor Detail

SLQueue

public SLQueue()
Construct an empty SLQueue.

Method Detail

enqueue

public void enqueue(java.lang.Object item)
Insert an Object in the queue.

Specified by:
enqueue in interface Queue
Parameters:
item - the Object to be inserted

dequeue

public java.lang.Object dequeue()
                         throws EmptyQueueException
Remove an Object from the queue.

Specified by:
dequeue in interface Queue
Returns:
the Object removed
Throws:
EmptyQueueException - if the Queue is empty

isEmpty

public boolean isEmpty()
Indicate whether or not the Queue is empty

Specified by:
isEmpty in interface Queue
Returns:
boolean indicating whether or not the Queue is empty