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.19 by tim, Mon Aug 4 16:14:48 2003 UTC vs.
Revision 1.20 by dholmes, Tue Aug 5 06:18:17 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
7   * {@link java.util.TreeMap}: elements are ordered
# 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 118 | Line 118 | public class PriorityQueue<E> extends Ab
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.
121 >     * size of the specified collection or 1 if the collection is empty.
122       * If the specified collection
123       * implements the {@link Sorted} interface, the priority queue will be
124       * sorted according to the same comparator, or according to its elements'
# Line 145 | Line 144 | public class PriorityQueue<E> extends Ab
144  
145          this.queue = new Object[initialCapacity + 1];
146  
148        // FIXME: if c is larger than Integer.MAX_VALUE we'll
149        // overflow the array
150
147          if (c instanceof Sorted) {
148              comparator = (Comparator<? super E>)((Sorted)c).comparator();
149          } else {
# Line 176 | Line 172 | public class PriorityQueue<E> extends Ab
172          ++size;
173  
174          // Grow backing store if necessary
179        // FIXME: watch for overflow
180        // FIXME: what if we're full?
175          while (size >= queue.length) {
176              Object[] newQueue = new Object[2 * queue.length];
177              System.arraycopy(queue, 0, newQueue, 0, queue.length);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines