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.18 by dholmes, Mon Aug 4 01:48:39 2003 UTC vs.
Revision 1.21 by dholmes, Tue Aug 5 06:49:51 2003 UTC

# Line 1 | Line 1
1   package java.util;
2  
3   /**
4 < * A priority queue based on a priority heap.  This queue orders
4 > * An unbounded priority queue based on a priority heap.  This queue orders
5   * elements according to an order specified at construction time, which is
6 < * specified in the same manner as {@link java.util.TreeSet} and
6 > * specified in the same manner as {@link java.util.TreeSet} and
7   * {@link java.util.TreeMap}: elements are ordered
8   * either according to their <i>natural order</i> (see {@link Comparable}), or
9 < * according to a {@link java.util.Comparator}, depending on which
9 > * according to a {@link java.util.Comparator}, depending on which
10   * constructor is used.
11 < * <p>The <em>head</em> of this queue is the <em>least</em> element with
12 < * respect to the specified ordering.
11 > * <p>The <em>head</em> of this queue is the <em>least</em> element with
12 > * respect to the specified ordering.
13   * If multiple elements are tied for least value, the
14   * head is one of those elements. A priority queue does not permit
15   * <tt>null</tt> elements.
# Line 22 | Line 22
22   *
23   * <p>A priority queue has a <i>capacity</i>.  The capacity is the
24   * size of the array used internally to store the elements on the
25 < * queue, and is limited to <tt>Integer.MAX_VALUE-1</tt>.  
25 > * queue.
26   * It is always at least as large as the queue size.  As
27   * elements are added to a priority queue, its capacity grows
28   * automatically.  The details of the growth policy are not specified.
# Line 78 | Line 78 | public class PriorityQueue<E> extends Ab
78      private transient int modCount = 0;
79  
80      /**
81 <     * Create a <tt>PriorityQueue</tt> with the default initial capacity
81 >     * Creates a <tt>PriorityQueue</tt> with the default initial capacity
82       * (11) that orders its elements according to their natural
83       * ordering (using <tt>Comparable</tt>.)
84       */
# Line 87 | Line 87 | public class PriorityQueue<E> extends Ab
87      }
88  
89      /**
90 <     * Create a <tt>PriorityQueue</tt> with the specified initial capacity
90 >     * Creates a <tt>PriorityQueue</tt> with the specified initial capacity
91       * that orders its elements according to their natural ordering
92       * (using <tt>Comparable</tt>.)
93       *
# Line 98 | Line 98 | public class PriorityQueue<E> extends Ab
98      }
99  
100      /**
101 <     * Create a <tt>PriorityQueue</tt> with the specified initial capacity
101 >     * Creates a <tt>PriorityQueue</tt> with the specified initial capacity
102       * that orders its elements according to the specified comparator.
103       *
104       * @param initialCapacity the initial capacity for this priority queue.
# Line 116 | Line 116 | public class PriorityQueue<E> extends Ab
116      }
117  
118      /**
119 <     * Create a <tt>PriorityQueue</tt> containing the elements in the specified
120 <     * collection.  The priority queue has an initial capacity of 110% of the
121 <     * size of the specified collection (bounded by
122 <     * <tt>Integer.MAX_VALUE-1</tt>); or 1 if the collection is empty.
119 >     * Creates a <tt>PriorityQueue</tt> containing the elements in the
120 >     * specified collection.  
121 >     * The priority queue has an initial capacity of 110% of the
122 >     * size of the specified collection or 1 if the collection is empty.
123       * If the specified collection
124       * implements the {@link Sorted} interface, the priority queue will be
125       * sorted according to the same comparator, or according to its elements'
# Line 145 | Line 145 | public class PriorityQueue<E> extends Ab
145  
146          this.queue = new Object[initialCapacity + 1];
147  
148        // FIXME: if c is larger than Integer.MAX_VALUE we'll
149        // overflow the array
150
148          if (c instanceof Sorted) {
149 <            comparator = ((Sorted)c).comparator();
149 >            comparator = (Comparator<? super E>)((Sorted)c).comparator();
150          } else {
151              comparator = null;
152          }
# Line 176 | Line 173 | public class PriorityQueue<E> extends Ab
173          ++size;
174  
175          // Grow backing store if necessary
179        // FIXME: watch for overflow
180        // FIXME: what if we're full?
176          while (size >= queue.length) {
177              Object[] newQueue = new Object[2 * queue.length];
178              System.arraycopy(queue, 0, newQueue, 0, queue.length);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines