Class bdd.util.FIFOQueue
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class bdd.util.FIFOQueue

java.lang.Object
   |
   +----bdd.util.FIFOQueue

public class FIFOQueue
extends Object
implements Enumeration
Written by Tim Macinta 1997
Distributed under the GNU Public License (a copy of which is enclosed with the source).

This class provides a simple First In First Out Queue. Please Note: this implementation of a FIFOQueue is not thread safe so if you plan on accessing the same queue with multiple threads you wil need to handle synchronization yourself (e.g., by creating a synchronized subclass).

Constructor Index

 o FIFOQueue()
 o FIFOQueue(int, int)
"initial_cap" specifies the initial capacity of the queue and "grow_size" specifies the amount that the capacity grows by when capacity is reached.

Method Index

 o addElement(Object)
Adds "object" to the queue.
 o countElements()
Returns the number of elements in this queue.
 o hasMoreElements()
Returns true if this queue contains more elements and false otherwise.
 o nextElement()
Removes the next element from the queue and returns it.
 o readNextElement()
Returns the next element that on the queue, but leaves the element on the queue so that the next call to nextElement() or readNextElement() will return the same element.
 o setCapacity(int)
Conserves memory by shrinking the capacity of the queue to "new_capacity".
 o shrinkCapacityToSize()
Sets the capacity to the number of elements in the queue.

Constructors

 o FIFOQueue
  public FIFOQueue()
 o FIFOQueue
  public FIFOQueue(int initial_cap,
                   int grow_size)
"initial_cap" specifies the initial capacity of the queue and "grow_size" specifies the amount that the capacity grows by when capacity is reached. Both parameters must be positive.

Methods

 o addElement
  public void addElement(Object object)
Adds "object" to the queue. "object" CAN be null.
 o nextElement
  public Object nextElement()
Removes the next element from the queue and returns it.

Throws a java.util.NoSuchElementException if the queue is empty.

 o readNextElement
  public Object readNextElement()
Returns the next element that on the queue, but leaves the element on the queue so that the next call to nextElement() or readNextElement() will return the same element.

Throws a java.util.NoSuchElementException if the queue is empty.

 o hasMoreElements
  public boolean hasMoreElements()
Returns true if this queue contains more elements and false otherwise.
 o countElements
  public int countElements()
Returns the number of elements in this queue.
 o setCapacity
  public void setCapacity(int new_capacity)
Conserves memory by shrinking the capacity of the queue to "new_capacity". Of course, you can also use this method to manually grow the size of the queue, but this is unecessary. "new_capacity" should be greater than or equal to the number of elements in the queue - if it is less than the number of elements in the queue, the capacity will be set to the number of elements in the queue.
 o shrinkCapacityToSize
  public void shrinkCapacityToSize()
Sets the capacity to the number of elements in the queue. Equivalent to setCapacity(countElements()) .

All Packages  Class Hierarchy  This Package  Previous  Next  Index