Known Indirect Subclasses
AbstractQueue<E>,
ArrayBlockingQueue<E>,
ArrayDeque<E>,
BlockingDeque<E>,
BlockingQueue<E>,
ConcurrentLinkedQueue<E>,
DelayQueue<E extends Delayed>,
Deque<E>,
LinkedBlockingDeque<E>,
LinkedBlockingQueue<E>,
LinkedList<E>,
PriorityBlockingQueue<E>,
PriorityQueue<E>,
SynchronousQueue<E>
AbstractQueue<E> |
AbstractQueue is an abstract class which implements some of the methods in
Queue . |
ArrayBlockingQueue<E> |
A bounded blocking queue backed by an
array. |
ArrayDeque<E> |
An implementation of Deque, backed by an array. |
BlockingDeque<E> |
A Deque that additionally supports blocking operations that wait
for the deque to become non-empty when retrieving an element, and wait for
space to become available in the deque when storing an element. |
BlockingQueue<E> |
A Queue that additionally supports operations
that wait for the queue to become non-empty when retrieving an
element, and wait for space to become available in the queue when
storing an element. |
ConcurrentLinkedQueue<E> |
An unbounded thread-safe queue based on linked nodes. |
DelayQueue<E extends Delayed> |
An unbounded blocking queue of
Delayed elements, in which an element can only be taken
when its delay has expired. |
Deque<E> |
A kind of collection that can insert or remove element at both ends("double
ended queue"). |
LinkedBlockingDeque<E> |
An optionally-bounded blocking deque based on
linked nodes. |
LinkedBlockingQueue<E> |
An optionally-bounded blocking queue based on
linked nodes. |
LinkedList<E> |
LinkedList is an implementation of List , backed by a doubly-linked list. |
PriorityBlockingQueue<E> |
An unbounded blocking queue that uses
the same ordering rules as class PriorityQueue and supplies
blocking retrieval operations. |
PriorityQueue<E> |
A PriorityQueue holds elements on a priority heap, which orders the elements
according to their natural order or according to the comparator specified at
construction time. |
SynchronousQueue<E> |
A blocking queue in which each insert
operation must wait for a corresponding remove operation by another
thread, and vice versa. |
|
Class Overview
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.
Summary
Public Methods |
abstract
E
|
element()
Gets but does not remove the element at the head of the queue.
|
abstract
boolean
|
offer(E o)
Inserts the specified element into the queue provided that the condition
allows such an operation.
|
abstract
E
|
peek()
Gets but does not remove the element at the head of the queue.
|
abstract
E
|
poll()
Gets and removes the element at the head of the queue, or returns null if there is no element in the queue.
|
abstract
E
|
remove()
Gets and removes the element at the head of the queue.
|
[Expand]
Inherited Methods |
From interface java.lang.Iterable
|
From interface java.util.Collection
abstract
boolean
|
add(E object)
Attempts to add object to the contents of this
Collection (optional).
|
abstract
boolean
|
addAll(Collection<? extends E> collection)
Attempts to add all of the objects contained in Collection
to the contents of this Collection (optional).
|
abstract
void
|
clear()
Removes all elements from this Collection , leaving it empty (optional).
|
abstract
boolean
|
contains(Object object)
Tests whether this Collection contains the specified object.
|
abstract
boolean
|
containsAll(Collection<?> collection)
Tests whether this Collection contains all objects contained in the
specified Collection .
|
abstract
boolean
|
equals(Object object)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
abstract
int
|
hashCode()
Returns an integer hash code for the receiver.
|
abstract
boolean
|
isEmpty()
Returns if this Collection contains no elements.
|
abstract
Iterator<E>
|
iterator()
Returns an instance of Iterator that may be used to access the
objects contained by this Collection .
|
abstract
boolean
|
remove(Object object)
Removes one instance of the specified object from this Collection if one
is contained (optional).
|
abstract
boolean
|
removeAll(Collection<?> collection)
Removes all occurrences in this Collection of each object in the
specified Collection (optional).
|
abstract
boolean
|
retainAll(Collection<?> collection)
Removes all objects from this Collection that are not also found in the
Collection passed (optional).
|
abstract
int
|
size()
Returns a count of how many objects this Collection contains.
|
abstract
<T>
T[]
|
toArray(T[] array)
Returns an array containing all elements contained in this Collection .
|
abstract
Object[]
|
toArray()
Returns a new array containing all elements contained in this Collection .
|
|
Public Methods
public
abstract
E
element
()
Gets but does not remove the element at the head of the queue. Throws a
NoSuchElementException
if there is no element in the queue.
Returns
- the element at the head of the queue.
public
abstract
boolean
offer
(E o)
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.
Parameters
o
| the specified element to insert into the queue. |
Returns
true
if the operation succeeds and false
if it
fails.
public
abstract
E
peek
()
Gets but does not remove the element at the head of the queue.
Returns
- the element at the head of the queue or
null
if there is
no element in the queue.
public
abstract
E
poll
()
Gets and removes the element at the head of the queue, or returns null
if there is no element in the queue.
Returns
- the element at the head of the queue or
null
if there is
no element in the queue.
public
abstract
E
remove
()
Gets and removes the element at the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Returns
- the element at the head of the queue.