--- 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:49:51 1.21
@@ -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.
@@ -78,7 +78,7 @@ public class PriorityQueue extends Ab
private transient int modCount = 0;
/**
- * Create a PriorityQueue with the default initial capacity
+ * Creates a PriorityQueue with the default initial capacity
* (11) that orders its elements according to their natural
* ordering (using Comparable.)
*/
@@ -87,7 +87,7 @@ public class PriorityQueue extends Ab
}
/**
- * Create a PriorityQueue with the specified initial capacity
+ * Creates a PriorityQueue with the specified initial capacity
* that orders its elements according to their natural ordering
* (using Comparable.)
*
@@ -98,7 +98,7 @@ public class PriorityQueue extends Ab
}
/**
- * Create a PriorityQueue with the specified initial capacity
+ * Creates a PriorityQueue with the specified initial capacity
* that orders its elements according to the specified comparator.
*
* @param initialCapacity the initial capacity for this priority queue.
@@ -116,10 +116,10 @@ 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.
+ * Creates 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 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 +145,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 super E>)((Sorted)c).comparator();
} else {
comparator = null;
}
@@ -176,8 +173,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);