jsim.queue
Class FIFO_Queue

java.lang.Object
  extended by jsim.queue.Queue
      extended by jsim.queue.FIFO_Queue
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List

public class FIFO_Queue
extends Queue

FIFO_Queue class implements the First_In_First_Out queue. The implementation is based on the Pascal implementation in Data Structures by Rick Decker.

Version:
1.0
Author:
John Miller, Zhiwei Zhang

Field Summary
 
Fields inherited from class jsim.queue.Queue
capacity, root, size
 
Constructor Summary
FIFO_Queue()
          Constructs an empty FIFO queue with unlimited capacity.
FIFO_Queue(int capacity)
          Constructs an empty FIFO queue with limited capacity.
 
Method Summary
 Q_Node addAt(java.lang.Object item)
          Insert an element into the queue.
 void clear()
          Clear all elements from the queue.
protected  void removeMin()
          Remove the node containing the minimum/first element from the queue.
 
Methods inherited from class jsim.queue.Queue
add, add, addAll, addAll, cancel, contains, containsAll, first, get, indexOf, isEmpty, isFull, iterator, lastIndexOf, listIterator, listIterator, remove, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

FIFO_Queue

public FIFO_Queue()
Constructs an empty FIFO queue with unlimited capacity.


FIFO_Queue

public FIFO_Queue(int capacity)
Constructs an empty FIFO queue with limited capacity.

Parameters:
capacity - the maximum number of items queue can hold.
Method Detail

addAt

public Q_Node addAt(java.lang.Object item)
             throws FullQueueException
Insert an element into the queue.

Specified by:
addAt in class Queue
Parameters:
item - new item to be inserted
Returns:
Q_Node node holding the new item
Throws:
FullQueueException - if queue is full

removeMin

protected void removeMin()
Remove the node containing the minimum/first element from the queue.

Overrides:
removeMin in class Queue

clear

public void clear()
Clear all elements from the queue.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class Queue