/* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain. Use, modify, and * redistribute this code in any way without acknowledgement. */ package java.util; /** * This class provides skeletal implementations of some {@link Queue} * operations. The implementations in this class are appropriate when * the base implementation does not allow null * elements. Methods {@link #add add}, {@link #remove remove}, and * {@link #element element} are based on {@link #offer offer}, {@link * #poll poll}, and {@link #peek 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 {@link Queue#offer} which does not permit
* insertion of null elements, along with methods {@link
* Queue#peek}, {@link Queue#poll}, {@link Collection#size}, and a
* {@link Collection#iterator} supporting {@link
* Iterator#remove}. Typically, additional methods will be overriden
* as well. If these requirements cannot be met, consider instead
* subclassing {@link AbstractCollection}.
*
* @since 1.5
* @author Doug Lea
*/
public abstract class AbstractQueue This implementation repeatedly invokes {@link #poll poll} until it
* returns null.
*/
public void clear() {
while (poll() != null)
;
}
}