--- jsr166/src/main/java/util/PriorityQueue.java 2003/09/13 18:51:06 1.41 +++ jsr166/src/main/java/util/PriorityQueue.java 2004/04/10 14:31:46 1.47 @@ -14,14 +14,16 @@ package java.util; * natural order (see {@link Comparable}), or according to a * {@link java.util.Comparator}, depending on which constructor is * used. A priority queue does not permit null elements. + * A priority queue relying on natural ordering also does not + * permit insertion of non-comparable objects (doing so may result + * in ClassCastException). * *

The head of this queue is the least element * with respect to the specified ordering. If multiple elements are * tied for least value, the head is one of those elements -- ties are - * broken arbitrarily. The {@link #remove()} and {@link #poll()} - * methods remove and return the head of the queue, and the {@link - * #element()} and {@link #peek()} methods return, but do not delete, - * the head of the queue. + * broken arbitrarily. The queue retrieval operations poll, + * remove, peek, and element access the + * element at the head of the queue. * *

A priority queue is unbounded, but has an internal * capacity governing the size of an array used to store the @@ -57,9 +59,10 @@ package java.util; * @since 1.5 * @version %I%, %G% * @author Josh Bloch + * @param the type of elements held in this collection */ public class PriorityQueue extends AbstractQueue - implements Queue, java.io.Serializable { + implements java.io.Serializable { private static final long serialVersionUID = -7720805057305804111L; @@ -196,8 +199,7 @@ public class PriorityQueue extends Ab public PriorityQueue(Collection c) { initializeArray(c); if (c instanceof SortedSet) { - // @fixme double-cast workaround for compiler - SortedSet s = (SortedSet) (SortedSet)c; + SortedSet s = (SortedSet)c; comparator = (Comparator)s.comparator(); fillFromSorted(s); } else if (c instanceof PriorityQueue) { @@ -278,7 +280,7 @@ public class PriorityQueue extends Ab /** - * Inserts the specified element to this priority queue. + * Inserts the specified element into this priority queue. * * @return true * @throws ClassCastException if the specified element cannot be compared @@ -323,29 +325,6 @@ public class PriorityQueue extends Ab return offer(o); } - - /** - * Adds all of the elements in the specified collection to this queue. - * The behavior of this operation is undefined if - * the specified collection is modified while the operation is in - * progress. (This implies that the behavior of this call is undefined if - * the specified collection is this queue, and this queue is nonempty.) - *

- * This implementation iterates over the specified collection, and adds - * each object returned by the iterator to this collection, in turn. - * @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 c or any element in c - * is null - * @throws ClassCastException if any element cannot be compared - * with elements currently in the priority queue according - * to the priority queue's ordering. - */ - public boolean addAll(Collection c) { - return super.addAll(c); - } - public boolean remove(Object o) { if (o == null) return false;