--- jsr166/src/main/java/util/AbstractQueue.java 2003/11/10 17:31:18 1.22 +++ jsr166/src/main/java/util/AbstractQueue.java 2005/05/02 08:35:49 1.27 @@ -1,7 +1,7 @@ /* * 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. + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/licenses/publicdomain */ package java.util; @@ -25,6 +25,10 @@ package java.util; * as well. If these requirements cannot be met, consider instead * subclassing {@link AbstractCollection}. * + *

This class is a member of the + * + * Java Collections Framework. + * * @since 1.5 * @author Doug Lea * @param the type of elements held in this collection @@ -43,17 +47,17 @@ public abstract class AbstractQueue /** * Adds the specified element to this queue. This implementation * returns true if offer succeeds, else - * throws an IllegalStateException. - * - * @param o the element + * throws an IllegalStateException. + * + * @param e the element * @return true (as per the general contract of * Collection.add). * - * @throws NullPointerException if the specified element is null - * @throws IllegalStateException if element cannot be added + * @throws NullPointerException if the specified element is null. + * @throws IllegalStateException if the element cannot be added. */ - public boolean add(E o) { - if (offer(o)) + public boolean add(E e) { + if (offer(e)) return true; else throw new IllegalStateException("Queue full"); @@ -75,9 +79,8 @@ public abstract class AbstractQueue throw new NoSuchElementException(); } - /** - * Retrieves, but does not remove, the head of this queue. + * Retrieves, but does not remove, the head of this queue. * This implementation returns the result of peek * unless the queue is empty. * @@ -93,8 +96,8 @@ public abstract class AbstractQueue } /** - * Removes all of the elements from this collection. - * The collection will be empty after this call returns. + * Removes all of the elements from this queue. + * The queue will be empty after this call returns. *

This implementation repeatedly invokes {@link #poll poll} until it * returns null. */ @@ -112,19 +115,19 @@ public abstract class AbstractQueue * *

This implementation iterates over the specified collection, * and adds each element returned by the iterator to this - * collection, in turn. A runtime exception encountered while + * queue, in turn. A runtime exception encountered while * trying to add an element (including, in particular, a * null element) may result in only some of the elements * having been successfully added when the associated exception is * thrown. * - * @param c collection whose elements are to be added to this collection. - * @return true if this collection changed as a result of the + * @param c collection whose elements are to be added to this queue. + * @return true if this queue changed as a result of the * call. * @throws NullPointerException if the specified collection or - * any of its elements are null. + * any of its elements are null. * @throws IllegalArgumentException if c is this queue. - * + * * @see #add(Object) */ public boolean addAll(Collection c) { @@ -132,13 +135,13 @@ public abstract class AbstractQueue throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); - boolean modified = false; - Iterator e = c.iterator(); - while (e.hasNext()) { - if (add(e.next())) - modified = true; - } - return modified; + boolean modified = false; + Iterator e = c.iterator(); + while (e.hasNext()) { + if (add(e.next())) + modified = true; + } + return modified; } }