All Packages Class Hierarchy This Package Previous Next Index
Class guinea.util.Queue
java.lang.Object
|
+----guinea.util.Queue
- public class Queue
- extends Object
- implements Serializable
The Queue object implements a queue. Objects
added to the queue go to end (tail) of the queue and objects are
removed from the head of the queue. Also an object can be removed
from anywhere in the queue. Also remove-methods can wait until
the queue becomes non-empty or the desired object has been added
to the queue.
Constructor Index
- ·
Queue()
- Construct a new empty queue.
- ·
Queue(Enumeration)
- Construct a new queue with the elements of an Enumeration as
the contents.
- ·
Queue(Object[])
- Construct a new queue with an array of objects as the
contents.
- ·
Queue(Vector)
- Construct a new queue with a vector of objects as the
contents.
Method Index
- ·
add(Object)
- Add an object to the end of the queue.
- ·
elements()
- Get an enumeration of objects in the queue.
- ·
elementsReverse()
- Get an enumeration of objects in the queue in reverse order.
- ·
isEmpty()
- Is queue empty?
- ·
remove()
- Remove the first object from the queue.
- ·
remove(Object)
- Remove from the queue the first object that 'equals' the
object given as a parameter.
- ·
removeWait()
- Remove the first object from the queue.
- ·
removeWait(Object)
- Remove from the queue the first object that 'equals' the
object given as a parameter.
- ·
setDebug(boolean)
-
- ·
size()
- Get the size (length) of the queue.
- ·
toString()
- Get a string representation of the queue.
Constructors
·
Queue
public Queue()
- Construct a new empty queue.
·
Queue
public Queue(Object objs[])
- Construct a new queue with an array of objects as the
contents. The first object in the queue is the first object
of the array.
- Parameters:
- objs - An array of object to add to the queue.
·
Queue
public Queue(Vector objs)
- Construct a new queue with a vector of objects as the
contents. The first object in the queue is the first object
of the vector.
- Parameters:
- objs - A vector of object to add to the queue.
·
Queue
public Queue(Enumeration objs)
- Construct a new queue with the elements of an Enumeration as
the contents. The first object in the queue is the first
object (element) that is got from the enumeration.
- Parameters:
- objs - An enumeration of objects to add to the queue.
Methods
·
setDebug
public void setDebug(boolean debug)
·
add
public void add(Object item)
- Add an object to the end of the queue.
- Parameters:
- item - the object to add to the queue.
·
remove
public Object remove()
- Remove the first object from the queue.
- Returns:
- the first object from the queue. If queue is empty,
null
is returned.
·
remove
public synchronized Object remove(Object item)
- Remove from the queue the first object that 'equals' the
object given as a parameter.
- Parameters:
- item - object which to compare to find an object from the
queue.
- Returns:
- first object that equals this item. If no matches is
found,
null
is returned.
·
removeWait
public synchronized Object removeWait(Object item) throws InterruptedException
- Remove from the queue the first object that 'equals' the
object given as a parameter. If a matching object is not in
the queue, will wait until it is added and then removed.
- Parameters:
- item - object which to compare to find an object from the
queue.
- Returns:
- first object that equals this item.
- Throws: InterruptedException
- the wait was interrupted.
·
removeWait
public synchronized Object removeWait() throws InterruptedException
- Remove the first object from the queue. If queue is empty,
will wait until queue is non-empty and then returns the first
object.
- Returns:
- the first object from the queue.
- Throws: InterruptedException
- the wait was interrupted.
·
size
public int size()
- Get the size (length) of the queue.
- Returns:
- number of objects in the queue.
·
isEmpty
public boolean isEmpty()
- Is queue empty?
- Returns:
-
true
if queue has no elements,
false
if it has.
·
elements
public Enumeration elements()
- Get an enumeration of objects in the queue.
- Returns:
- an enumeration of objects in the queue.
·
elementsReverse
public Enumeration elementsReverse()
- Get an enumeration of objects in the queue in reverse order.
- Returns:
- an enumeration of objects in the queue.
·
toString
public String toString()
- Get a string representation of the queue.
- Returns:
- a string.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index