--- jsr166/src/main/java/util/PriorityQueue.java 2003/08/04 01:48:39 1.18 +++ jsr166/src/main/java/util/PriorityQueue.java 2003/08/05 06:18:17 1.20 @@ -1,15 +1,15 @@ package java.util; /** - * A priority queue based on a priority heap. This queue orders + * An unbounded priority queue based on a priority heap. This queue orders * elements according to an order specified at construction time, which is - * specified in the same manner as {@link java.util.TreeSet} and + * specified in the same manner as {@link java.util.TreeSet} and * {@link java.util.TreeMap}: elements are ordered * either according to their natural order (see {@link Comparable}), or - * according to a {@link java.util.Comparator}, depending on which + * according to a {@link java.util.Comparator}, depending on which * constructor is used. - *

The head of this queue is the least element with - * respect to the specified ordering. + *

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. A priority queue does not permit * null elements. @@ -22,7 +22,7 @@ * *

A priority queue has a capacity. The capacity is the * size of the array used internally to store the elements on the - * queue, and is limited to Integer.MAX_VALUE-1. + * queue. * It is always at least as large as the queue size. As * elements are added to a priority queue, its capacity grows * automatically. The details of the growth policy are not specified. @@ -118,8 +118,7 @@ public class PriorityQueue extends Ab /** * Create a PriorityQueue containing the elements in the specified * collection. The priority queue has an initial capacity of 110% of the - * size of the specified collection (bounded by - * Integer.MAX_VALUE-1); or 1 if the collection is empty. + * size of the specified collection or 1 if the collection is empty. * If the specified collection * implements the {@link Sorted} interface, the priority queue will be * sorted according to the same comparator, or according to its elements' @@ -145,11 +144,8 @@ public class PriorityQueue extends Ab this.queue = new Object[initialCapacity + 1]; - // FIXME: if c is larger than Integer.MAX_VALUE we'll - // overflow the array - if (c instanceof Sorted) { - comparator = ((Sorted)c).comparator(); + comparator = (Comparator)((Sorted)c).comparator(); } else { comparator = null; } @@ -176,8 +172,6 @@ public class PriorityQueue extends Ab ++size; // Grow backing store if necessary - // FIXME: watch for overflow - // FIXME: what if we're full? while (size >= queue.length) { Object[] newQueue = new Object[2 * queue.length]; System.arraycopy(queue, 0, newQueue, 0, queue.length);