1 |
|
/* |
2 |
< |
* @(#)PriorityQueue.java 1.8 05/08/27 |
2 |
> |
* %W% %E% |
3 |
|
* |
4 |
|
* Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
229 |
|
// Double size if small; else grow by 50% |
230 |
|
int newCapacity = ((oldCapacity < 64)? |
231 |
|
((oldCapacity + 1) * 2): |
232 |
< |
((oldCapacity * 3) / 2)); |
232 |
> |
((oldCapacity / 2) * 3)); |
233 |
> |
if (newCapacity < 0) // overflow |
234 |
> |
newCapacity = Integer.MAX_VALUE; |
235 |
|
if (newCapacity < minCapacity) |
236 |
|
newCapacity = minCapacity; |
237 |
|
queue = Arrays.copyOf(queue, newCapacity); |
311 |
|
|
312 |
|
/** |
313 |
|
* Version of remove using reference equality, not equals. |
314 |
< |
* Needed by iterator.remove |
314 |
> |
* Needed by iterator.remove. |
315 |
|
* |
316 |
|
* @param o element to be removed from this queue, if present |
317 |
< |
* @return <tt>true</tt> if removed. |
317 |
> |
* @return <tt>true</tt> if removed |
318 |
|
*/ |
319 |
|
boolean removeEq(Object o) { |
320 |
|
for (int i = 0; i < size; i++) { |
346 |
|
* maintained by this list. (In other words, this method must allocate |
347 |
|
* a new array). The caller is thus free to modify the returned array. |
348 |
|
* |
349 |
< |
* @return an array containing all of the elements in this queue. |
349 |
> |
* @return an array containing all of the elements in this queue |
350 |
|
*/ |
351 |
|
public Object[] toArray() { |
352 |
|
return Arrays.copyOf(queue, size); |