Known Indirect Subclasses
| AbstractQueue<E> |
An abstract class which gives out skeletal implementations for some methods
in Queue which include add, remove, and element that are based on offer,
poll, and peek except that they throw exception to indicate the occurrence of
some error instead of the return value of false or null. |
| ArrayBlockingQueue<E> |
A bounded blocking queue backed by an
array. |
| 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. |
| LinkedBlockingQueue<E> |
An optionally-bounded blocking queue based on
linked nodes. |
| LinkedList<E> |
LinkedList is an implementation of List, backed by a linked list. |
| PriorityBlockingQueue<E> |
An unbounded blocking queue that uses
the same ordering rules as class PriorityQueue and supplies
blocking retrieval operations. |
| PriorityQueue<E> |
PriorityQueue holds elements on a priority heap, which orders elements
according to the comparator specified at construction or their natural order. |
| SynchronousQueue<E> |
A blocking queue in which each
put must wait for a take, and vice versa. |
|
Class Overview
A kind of collection provides advanced operations than other basic
collections, such as insertion, extraction, and inspection.
Generally, a queue orders its elements by means of first-in-first-out. While
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 method poll return null to indicate that
there is no element left in the queue.
Queue does not provide blocking queue methods, which will block until the
operation of the method is allowed. BlockingQueue interface defines such
methods.
Summary
| Public Methods |
|
abstract
E
|
element()
Gets but not removes the element in 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 not removes the element in the head of the queue, or throws
exception if there is no element in the queue.
|
|
abstract
E
|
poll()
Gets and removes the element in the head of the queue, or returns null if
there is no element in the queue.
|
|
abstract
E
|
remove()
Gets and removes the element in 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.
|
|
abstract
boolean
|
addAll(Collection<? extends E> collection)
Attempts to add all of the objects contained in collection
to the contents of this collection.
|
|
abstract
void
|
clear()
Removes all elements from this Collection, leaving it empty.
|
|
abstract
boolean
|
contains(Object object)
Searches this Collection for the specified object.
|
|
abstract
boolean
|
containsAll(Collection<?> collection)
Searches this Collection for all objects 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 has no elements, a size of zero.
|
|
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 the first occurrence of the specified object from this
Collection.
|
|
abstract
boolean
|
removeAll(Collection<?> collection)
Removes all occurrences in this Collection of each object in the
specified Collection.
|
|
abstract
boolean
|
retainAll(Collection<?> collection)
Removes all objects from this Collection that are not also found in the
contents of collection.
|
|
abstract
int
|
size()
Returns a count of how many objects are contained by this collection.
|
|
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 not removes the element in the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Returns
- the element in 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 the
collection.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 not removes the element in the head of the queue, or throws
exception if there is no element in the queue.
Returns
- the element in the head of the queue or null if there is no
element in the queue.
public
abstract
E
poll
()
Gets and removes the element in the head of the queue, or returns null if
there is no element in the queue.
Returns
- the element in the head of the queue or null if there is no
element in the queue.
public
abstract
E
remove
()
Gets and removes the element in the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Returns
- the element in the head of the queue.