openlist
Class Queue<Type>

java.lang.Object
  extended by openlist.Queue<Type>

public class Queue<Type>
extends java.lang.Object

A Queue is a first-in, first-out repository.


Field Summary
private  OpenList<Type> in
          Two lists are used.
private  OpenList<Type> out
           
 
Constructor Summary
Queue()
          Create an empty queue.
 
Method Summary
 Type dequeue()
          Dequeue an item from the Queue.
 void enqueue(Type item)
          Enqueue one item to the Queue.
 boolean isEmpty()
          Indicate whether or not the Queue is empty
 boolean nonEmpty()
          Indicate whether or not the Queue is non-empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private OpenList<Type> in
Two lists are used. Newly enqueued items are "pushed" onto the in list. Dequeued items are "popped" from the out list. When the out list becomes empty, any items on the in list are copied in reverse to the out list.


out

private OpenList<Type> out
Constructor Detail

Queue

public Queue()
Create an empty queue.

Method Detail

enqueue

public void enqueue(Type item)
Enqueue one item to the Queue.

Parameters:
item - the item to be enqueued

dequeue

public Type dequeue()
Dequeue an item from the Queue.

Returns:
the dequeued item

isEmpty

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

Returns:
true if the Queue is empty, otherwise false

nonEmpty

public boolean nonEmpty()
Indicate whether or not the Queue is non-empty

Returns:
true if the Queue is non-empty, otherwise false