com.mhhe.clrs2e
Class QueueList

java.lang.Object
  |
  +--com.mhhe.clrs2e.QueueList

public class QueueList
extends java.lang.Object

Defines a queue based on a SentinelDLL.


Field Summary
private  com.mhhe.clrs2e.SentinelDLL list
          The list implementing the queue.
 
Constructor Summary
QueueList()
          Makes an empty queue.
 
Method Summary
 java.lang.Object dequeue()
          Removes an element from the head of the queue.
 java.lang.Object enqueue(java.lang.Object o)
          Inserts an element at the tail of the queue.
 boolean isEmpty()
          Returns true if the list is empty (containing only its sentinel), and false otherwise.
 java.lang.String toString()
          Returns the String representation of this queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

private com.mhhe.clrs2e.SentinelDLL list
The list implementing the queue.

Constructor Detail

QueueList

public QueueList()
Makes an empty queue.

Method Detail

enqueue

public java.lang.Object enqueue(java.lang.Object o)
Inserts an element at the tail of the queue.

Parameters:
o - The element inserted.
Returns:
A handle to the new element.

dequeue

public java.lang.Object dequeue()
Removes an element from the head of the queue.

Returns:
The removed element.
Throws:
java.lang.IllegalStateException - if the queue is empty at the time of the call.

isEmpty

public boolean isEmpty()
Returns true if the list is empty (containing only its sentinel), and false otherwise.


toString

public java.lang.String toString()
Returns the String representation of this queue.

Overrides:
toString in class java.lang.Object