ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/PriorityQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/PriorityQueue.java (file contents):
Revision 1.67 by jsr166, Sun May 20 07:54:01 2007 UTC vs.
Revision 1.69 by jsr166, Sun May 18 23:59:57 2008 UTC

# Line 74 | Line 74 | package java.util;
74   * Java Collections Framework</a>.
75   *
76   * @since 1.5
77 * @version %I%, %G%
77   * @author Josh Bloch, Doug Lea
78   * @param <E> the type of elements held in this collection
79   */
# Line 244 | Line 243 | public class PriorityQueue<E> extends Ab
243      private void grow(int minCapacity) {
244          if (minCapacity < 0) // overflow
245              throw new OutOfMemoryError();
246 <        int oldCapacity = queue.length;
246 >        int oldCapacity = queue.length;
247          // Double size if small; else grow by 50%
248          int newCapacity = ((oldCapacity < 64)?
249                             ((oldCapacity + 1) * 2):
# Line 300 | Line 299 | public class PriorityQueue<E> extends Ab
299      }
300  
301      private int indexOf(Object o) {
302 <        if (o != null) {
302 >        if (o != null) {
303              for (int i = 0; i < size; i++)
304                  if (o.equals(queue[i]))
305                      return i;
# Line 320 | Line 319 | public class PriorityQueue<E> extends Ab
319       * @return {@code true} if this queue changed as a result of the call
320       */
321      public boolean remove(Object o) {
322 <        int i = indexOf(o);
323 <        if (i == -1)
324 <            return false;
325 <        else {
326 <            removeAt(i);
327 <            return true;
328 <        }
322 >        int i = indexOf(o);
323 >        if (i == -1)
324 >            return false;
325 >        else {
326 >            removeAt(i);
327 >            return true;
328 >        }
329      }
330  
331      /**
# Line 337 | Line 336 | public class PriorityQueue<E> extends Ab
336       * @return {@code true} if removed
337       */
338      boolean removeEq(Object o) {
339 <        for (int i = 0; i < size; i++) {
340 <            if (o == queue[i]) {
339 >        for (int i = 0; i < size; i++) {
340 >            if (o == queue[i]) {
341                  removeAt(i);
342                  return true;
343              }
# Line 355 | Line 354 | public class PriorityQueue<E> extends Ab
354       * @return {@code true} if this queue contains the specified element
355       */
356      public boolean contains(Object o) {
357 <        return indexOf(o) != -1;
357 >        return indexOf(o) != -1;
358      }
359  
360      /**
# Line 416 | Line 415 | public class PriorityQueue<E> extends Ab
415          if (a.length < size)
416              // Make a new array of a's runtime type, but my contents:
417              return (T[]) Arrays.copyOf(queue, size, a.getClass());
418 <        System.arraycopy(queue, 0, a, 0, size);
418 >        System.arraycopy(queue, 0, a, 0, size);
419          if (a.length > size)
420              a[size] = null;
421          return a;
# Line 509 | Line 508 | public class PriorityQueue<E> extends Ab
508                  lastRetElt = null;
509              } else {
510                  throw new IllegalStateException();
511 <            }
511 >            }
512              expectedModCount = modCount;
513          }
514      }
# Line 725 | Line 724 | public class PriorityQueue<E> extends Ab
724          // Read in (and discard) array length
725          s.readInt();
726  
727 <        queue = new Object[size];
727 >        queue = new Object[size];
728  
729          // Read in all elements.
730          for (int i = 0; i < size; i++)
731              queue[i] = s.readObject();
732  
733 <        // Elements are guaranteed to be in "proper order", but the
734 <        // spec has never explained what that might be.
735 <        heapify();
733 >        // Elements are guaranteed to be in "proper order", but the
734 >        // spec has never explained what that might be.
735 >        heapify();
736      }
737   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines