Java Queue class

java.util

Interface Queue<E>

Type Parameters:

E - the type of elements held in this collection

All Superinterfaces:

Collection<E>, Iterable<E>

All Known Subinterfaces:

BlockingQueue<E>

All Known Implementing Classes:

AbstractQueue, ArrayBlockingQueue, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingQueue, LinkedList, PriorityBlockingQueue, PriorityQueue, SynchronousQueue


public interface Queue<E>

extends Collection<E>

A collection designed for holding elements prior to processing. Besides basic Collection operations, queues provide additional insertion, extraction, and inspection operations.

Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the elements LIFO (last-in-first-out). Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). In a FIFO queue, all new elements are inserted at the tail of the queue. Other kinds of queues may use different placement rules. Every Queue implementation must specify its ordering properties


Method Summary

 E

element()
          Retrieves, but does not remove, the head of this queue.

 boolean

offer(E o)
          Inserts the specified element into this queue, if possible.

 E

peek()
          Retrieves, but does not remove, the head of this queue, returning
null if this queue is empty.

 E

poll()
          Retrieves and removes the head of this queue, or
null if this queue is empty.

 E

remove()
          Retrieves and removes the head of this queue.