--- jsr166/src/main/java/util/PriorityQueue.java 2006/05/28 23:36:29 1.65 +++ jsr166/src/main/java/util/PriorityQueue.java 2008/05/18 23:59:57 1.69 @@ -1,8 +1,26 @@ /* - * %W% %E% + * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. */ package java.util; @@ -56,7 +74,6 @@ package java.util; * Java Collections Framework. * * @since 1.5 - * @version %I%, %G% * @author Josh Bloch, Doug Lea * @param the type of elements held in this collection */ @@ -226,7 +243,7 @@ public class PriorityQueue extends Ab private void grow(int minCapacity) { if (minCapacity < 0) // overflow throw new OutOfMemoryError(); - int oldCapacity = queue.length; + int oldCapacity = queue.length; // Double size if small; else grow by 50% int newCapacity = ((oldCapacity < 64)? ((oldCapacity + 1) * 2): @@ -282,7 +299,7 @@ public class PriorityQueue extends Ab } private int indexOf(Object o) { - if (o != null) { + if (o != null) { for (int i = 0; i < size; i++) if (o.equals(queue[i])) return i; @@ -302,13 +319,13 @@ public class PriorityQueue extends Ab * @return {@code true} if this queue changed as a result of the call */ public boolean remove(Object o) { - int i = indexOf(o); - if (i == -1) - return false; - else { - removeAt(i); - return true; - } + int i = indexOf(o); + if (i == -1) + return false; + else { + removeAt(i); + return true; + } } /** @@ -319,8 +336,8 @@ public class PriorityQueue extends Ab * @return {@code true} if removed */ boolean removeEq(Object o) { - for (int i = 0; i < size; i++) { - if (o == queue[i]) { + for (int i = 0; i < size; i++) { + if (o == queue[i]) { removeAt(i); return true; } @@ -337,7 +354,7 @@ public class PriorityQueue extends Ab * @return {@code true} if this queue contains the specified element */ public boolean contains(Object o) { - return indexOf(o) != -1; + return indexOf(o) != -1; } /** @@ -398,7 +415,7 @@ public class PriorityQueue extends Ab if (a.length < size) // Make a new array of a's runtime type, but my contents: return (T[]) Arrays.copyOf(queue, size, a.getClass()); - System.arraycopy(queue, 0, a, 0, size); + System.arraycopy(queue, 0, a, 0, size); if (a.length > size) a[size] = null; return a; @@ -491,7 +508,7 @@ public class PriorityQueue extends Ab lastRetElt = null; } else { throw new IllegalStateException(); - } + } expectedModCount = modCount; } } @@ -707,14 +724,14 @@ public class PriorityQueue extends Ab // Read in (and discard) array length s.readInt(); - queue = new Object[size]; + queue = new Object[size]; // Read in all elements. for (int i = 0; i < size; i++) queue[i] = s.readObject(); - // Elements are guaranteed to be in "proper order", but the - // spec has never explained what that might be. - heapify(); + // Elements are guaranteed to be in "proper order", but the + // spec has never explained what that might be. + heapify(); } }