1 |
|
package java.util; |
2 |
|
|
3 |
|
/** |
4 |
< |
* A priority queue based on a priority heap. This queue orders |
4 |
> |
* An unbounded priority queue based on a priority heap. This queue orders |
5 |
|
* elements according to an order specified at construction time, which is |
6 |
|
* specified in the same manner as {@link java.util.TreeSet} and |
7 |
|
* {@link java.util.TreeMap}: elements are ordered |
22 |
|
* |
23 |
|
* <p>A priority queue has a <i>capacity</i>. The capacity is the |
24 |
|
* size of the array used internally to store the elements on the |
25 |
< |
* queue, and is limited to <tt>Integer.MAX_VALUE-1</tt>. |
25 |
> |
* queue. |
26 |
|
* It is always at least as large as the queue size. As |
27 |
|
* elements are added to a priority queue, its capacity grows |
28 |
|
* automatically. The details of the growth policy are not specified. |
118 |
|
/** |
119 |
|
* Create a <tt>PriorityQueue</tt> containing the elements in the specified |
120 |
|
* collection. The priority queue has an initial capacity of 110% of the |
121 |
< |
* size of the specified collection (bounded by |
122 |
< |
* <tt>Integer.MAX_VALUE-1</tt>); or 1 if the collection is empty. |
121 |
> |
* size of the specified collection or 1 if the collection is empty. |
122 |
|
* If the specified collection |
123 |
|
* implements the {@link Sorted} interface, the priority queue will be |
124 |
|
* sorted according to the same comparator, or according to its elements' |
144 |
|
|
145 |
|
this.queue = new Object[initialCapacity + 1]; |
146 |
|
|
148 |
– |
// FIXME: if c is larger than Integer.MAX_VALUE we'll |
149 |
– |
// overflow the array |
150 |
– |
|
147 |
|
if (c instanceof Sorted) { |
148 |
|
comparator = (Comparator<? super E>)((Sorted)c).comparator(); |
149 |
|
} else { |
172 |
|
++size; |
173 |
|
|
174 |
|
// Grow backing store if necessary |
179 |
– |
// FIXME: watch for overflow |
180 |
– |
// FIXME: what if we're full? |
175 |
|
while (size >= queue.length) { |
176 |
|
Object[] newQueue = new Object[2 * queue.length]; |
177 |
|
System.arraycopy(queue, 0, newQueue, 0, queue.length); |