java.util.Queue<E> |
Known Indirect Subclasses
AbstractQueue<E>,
ArrayBlockingQueue<E>,
BlockingQueue<E>,
ConcurrentLinkedQueue<E>,
DelayQueue<E extends Delayed>,
LinkedBlockingQueue<E>,
LinkedList<E>,
PriorityBlockingQueue<E>,
PriorityQueue<E>,
SynchronousQueue<E>
|
This kind of collection provides advanced operations compared to basic collections, such as insertion, extraction, and inspection.
Generally, a queue orders its elements by means of first-in-first-out. However, a priority queue orders its elements according to a comparator specified or the elements' natural order. Furthermore, a stack orders its elements last-in-first out.
A typical queue does not allow null
to be inserted as its element,
while some implementations such as LinkedList
allow it. But null
should not be inserted even in these implementations, since the method
poll
returns null
to indicate that there is no element left
in the queue.
Queue
does not provide blocking queue methods, which would block
until the operation of the method is allowed. See the
BlockingQueue
interface for information about
blocking queue methods.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets but does not remove the element at the head of the queue.
| |||||||||||
Inserts the specified element into the queue provided that the condition
allows such an operation.
| |||||||||||
Gets but does not remove the element at the head of the queue.
| |||||||||||
Gets and removes the element at the head of the queue, or returns
null if there is no element in the queue. | |||||||||||
Gets and removes the element at the head of the queue.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface java.lang.Iterable
| |||||||||||
From interface java.util.Collection
|
Gets but does not remove the element at the head of the queue. Throws a
NoSuchElementException
if there is no element in the queue.
NoSuchElementException | if there is no element in the queue. |
---|
Inserts the specified element into the queue provided that the condition
allows such an operation. The method is generally preferable to
add(E)
, since the latter might throw an exception if the
operation fails.
o | the specified element to insert into the queue. |
---|
true
if the operation succeeds and false
if it
fails.
Gets but does not remove the element at the head of the queue.
null
if there is
no element in the queue.
Gets and removes the element at the head of the queue, or returns null
if there is no element in the queue.
null
if there is
no element in the queue.
Gets and removes the element at the head of the queue. Throws a NoSuchElementException if there is no element in the queue.
NoSuchElementException | if there is no element in the queue. |
---|