A collection designed for holding elements prior to processing.
Although all Queue implementations do not limit the amount of elements they can contain, this interface supports for capacity-bounded queues. When capacity is not bound, then the capacity and remaining_capacity both return UNBOUNDED_CAPACITY.
This interface defines methods that will never fail whatever the state of the queue is. For capacity-bounded queues, those methods will
either return false
or null
to specify that the insert or retrieval did not occur because the queue was full or
empty.
Queue implementations are not limited to First-In-First-Out behavior and can offer different orderings of their elements. Each Queue implementation must specify how it orders its elements.
Queue implementations do not allow insertion of null
elements, although some implementations, such as
LinkedList, do not prohibit insertion of null
. Even in the implementations
that permit it, null
should not be inserted into a Queue, as null
is also used as a special return value by the
poll method to indicate that the queue contains no elements.