--- jsr166/src/main/java/util/PriorityQueue.java 2005/11/28 02:35:46 1.56 +++ jsr166/src/main/java/util/PriorityQueue.java 2005/11/29 08:52:26 1.59 @@ -1,5 +1,5 @@ /* - * @(#)PriorityQueue.java 1.8 05/08/27 + * %W% %E% * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. @@ -229,7 +229,9 @@ public class PriorityQueue extends Ab // Double size if small; else grow by 50% int newCapacity = ((oldCapacity < 64)? ((oldCapacity + 1) * 2): - ((oldCapacity * 3) / 2)); + ((oldCapacity / 2) * 3)); + if (newCapacity < 0) // overflow + newCapacity = Integer.MAX_VALUE; if (newCapacity < minCapacity) newCapacity = minCapacity; queue = Arrays.copyOf(queue, newCapacity); @@ -309,10 +311,10 @@ public class PriorityQueue extends Ab /** * Version of remove using reference equality, not equals. - * Needed by iterator.remove + * Needed by iterator.remove. * * @param o element to be removed from this queue, if present - * @return true if removed. + * @return true if removed */ boolean removeEq(Object o) { for (int i = 0; i < size; i++) { @@ -344,7 +346,7 @@ public class PriorityQueue extends Ab * maintained by this list. (In other words, this method must allocate * a new array). The caller is thus free to modify the returned array. * - * @return an array containing all of the elements in this queue. + * @return an array containing all of the elements in this queue */ public Object[] toArray() { return Arrays.copyOf(queue, size);