util
Class Queue

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--util.Queue

public class Queue
extends Vector

The queue implements a first-in first-out (FIFO) set of objects. Much like java.util.Stack, it extends class Vector with enqueue and dequeue methods. Unlike java.util.Stack, there is no search routine. This is a very simple layer over the Vector class, which probably explains why there is no such thing as a queue class in java.util.*

See Also:
Vector, Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Queue()
          Creates an empty queue.
 
Method Summary
 Object dequeue()
          Removes the element from the head of the queue and returns it.
 boolean empty()
          Checks the queue for emptiness.
 void enqueue(Object o)
          Adds an element to the back of the queue.
 Object peek()
          Peeks at the first element of the queue, without removing.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Creates an empty queue.
Method Detail

empty

public boolean empty()
Checks the queue for emptiness.
Returns:
true if the queue has no elements.

enqueue

public void enqueue(Object o)
Adds an element to the back of the queue.
Parameters:
o - the object to be inserted into the queue.

dequeue

public Object dequeue()
Removes the element from the head of the queue and returns it.
Returns:
The element that was taken from the head of the queue.

peek

public Object peek()
Peeks at the first element of the queue, without removing.
Returns:
The element at the head of the queue.