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.7 by dl, Tue Jun 24 14:34:30 2003 UTC vs.
Revision 1.9 by dl, Sun Jul 13 22:51:22 2003 UTC

# Line 31 | Line 31
31   * @author Josh Bloch
32   */
33   public class PriorityQueue<E> extends AbstractQueue<E>
34 <                              implements Queue<E> {
34 >                              implements Queue<E>,
35 >                                         java.io.Serializable {
36      private static final int DEFAULT_INITIAL_CAPACITY = 11;
37  
38      /**
# Line 127 | Line 128 | public class PriorityQueue<E> extends Ab
128              initialCapacity = 1;
129          queue = new E[initialCapacity + 1];
130  
130        /* Commented out to compile with generics compiler
131  
132          if (initialElements instanceof Sorted) {
133              comparator = ((Sorted)initialElements).comparator();
134              for (Iterator<E> i = initialElements.iterator(); i.hasNext(); )
135                  queue[++size] = i.next();
136          } else {
137        */
138        {
137              comparator = null;
138              for (Iterator<E> i = initialElements.iterator(); i.hasNext(); )
139                  add(i.next());
# Line 301 | Line 299 | public class PriorityQueue<E> extends Ab
299          if (element == null)
300              throw new NullPointerException();
301          modCount++;
302 +        ++size;
303  
304          // Grow backing store if necessary
305 <        if (++size == queue.length) {
305 >        while (size >= queue.length) {
306              E[] newQueue = new E[2 * queue.length];
307 <            System.arraycopy(queue, 0, newQueue, 0, size);
307 >            System.arraycopy(queue, 0, newQueue, 0, queue.length);
308              queue = newQueue;
309          }
310  
# Line 414 | Line 413 | public class PriorityQueue<E> extends Ab
413       * @return the comparator associated with this priority queue, or
414       *         <tt>null</tt> if it uses its elements' natural ordering.
415       */
416 <    Comparator comparator() {
416 >    public Comparator comparator() {
417          return comparator;
418      }
419  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines