1 |
|
/* |
2 |
|
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
8 |
|
package java.util; |
9 |
– |
import java.util.*; // for javadoc (till 6280605 is fixed) |
9 |
|
|
10 |
|
/** |
11 |
|
* An unbounded priority {@linkplain Queue queue} based on a priority |
55 |
|
* <a href="{@docRoot}/../guide/collections/index.html"> |
56 |
|
* Java Collections Framework</a>. |
57 |
|
* @since 1.5 |
58 |
< |
* @version 1.8, 08/27/05 |
58 |
> |
* @version %I%, %G% |
59 |
|
* @author Josh Bloch |
60 |
|
* @param <E> the type of elements held in this collection |
61 |
|
*/ |
228 |
|
// Double size if small; else grow by 50% |
229 |
|
int newCapacity = ((oldCapacity < 64)? |
230 |
|
((oldCapacity + 1) * 2): |
231 |
< |
((oldCapacity * 3) / 2)); |
231 |
> |
((oldCapacity / 2) * 3)); |
232 |
> |
if (newCapacity < 0) // overflow |
233 |
> |
newCapacity = Integer.MAX_VALUE; |
234 |
|
if (newCapacity < minCapacity) |
235 |
|
newCapacity = minCapacity; |
236 |
|
queue = Arrays.copyOf(queue, newCapacity); |
310 |
|
|
311 |
|
/** |
312 |
|
* Version of remove using reference equality, not equals. |
313 |
< |
* Needed by iterator.remove |
313 |
> |
* Needed by iterator.remove. |
314 |
|
* |
315 |
|
* @param o element to be removed from this queue, if present |
316 |
< |
* @return <tt>true</tt> if removed. |
316 |
> |
* @return <tt>true</tt> if removed |
317 |
|
*/ |
318 |
|
boolean removeEq(Object o) { |
319 |
|
for (int i = 0; i < size; i++) { |
345 |
|
* maintained by this list. (In other words, this method must allocate |
346 |
|
* a new array). The caller is thus free to modify the returned array. |
347 |
|
* |
348 |
< |
* @return an array containing all of the elements in this queue. |
348 |
> |
* @return an array containing all of the elements in this queue |
349 |
|
*/ |
350 |
|
public Object[] toArray() { |
351 |
|
return Arrays.copyOf(queue, size); |