AbstractQueue
This class provides skeletal implementations of some Queue operations. The implementations in this class are appropriate when the base implementation does not allow null elements. Methods .add, .remove, and .element are based on .offer, .poll, and .peek, respectively, but throw exceptions instead of indicating failure via false or null returns.
A Queue implementation that extends this class must minimally define a method Queue.offer which does not permit insertion of null elements, along with methods , Queue.poll, Collection.size, and Collection.iterator. Typically, additional methods will be overridden as well. If these requirements cannot be met, consider instead subclassing AbstractCollection.
This class is a member of the {@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework.
Since
1.5
Author
Doug Lea
Parameters
Inheritors
Functions
Adds all of the elements in the specified collection to this queue. Attempts to addAll of a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to .add, which can fail to insert an element only by throwing an exception.