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).
-
FIFOQueue()
-
-
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.
-
addElement(Object)
- Adds "object" to the queue.
-
countElements()
- Returns the number of elements in this queue.
-
hasMoreElements()
- Returns true if this queue contains more elements and false otherwise.
-
nextElement()
- Removes the next element from the queue and returns it.
-
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.
-
setCapacity(int)
- Conserves memory by shrinking the capacity of the queue to
"new_capacity".
-
shrinkCapacityToSize()
- Sets the capacity to the number of elements in the queue.
FIFOQueue
public FIFOQueue()
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.
addElement
public void addElement(Object object)
- Adds "object" to the queue. "object" CAN be null.
nextElement
public Object nextElement()
- Removes the next element from the queue and returns it.
Throws a java.util.NoSuchElementException if the queue is empty.
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.
hasMoreElements
public boolean hasMoreElements()
- Returns true if this queue contains more elements and false otherwise.
countElements
public int countElements()
- Returns the number of elements in this queue.
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.
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