[cvs] / jsr166 / src / main / java / util / PriorityQueue.java Repository:
ViewVC logotype

Diff of /jsr166/src/main/java/util/PriorityQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19, Mon Aug 4 16:14:48 2003 UTC revision 1.20, Tue Aug 5 06:18:17 2003 UTC
# Line 1  Line 1 
1   package java.util;   package java.util;
2    
3  /**  /**
4   * A priority queue based on a priority heap.  This queue orders   * An unbounded priority queue based on a priority heap.  This queue orders
5   * elements according to an order specified at construction time, which is   * elements according to an order specified at construction time, which is
6   * specified in the same manner as {@link java.util.TreeSet} and   * specified in the same manner as {@link java.util.TreeSet} and
7   * {@link java.util.TreeMap}: elements are ordered   * {@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   * <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   * size of the array used internally to store the elements on the
25   * queue, and is limited to <tt>Integer.MAX_VALUE-1</tt>.   * queue.
26   * It is always at least as large as the queue size.  As   * It is always at least as large as the queue size.  As
27   * elements are added to a priority queue, its capacity grows   * elements are added to a priority queue, its capacity grows
28   * automatically.  The details of the growth policy are not specified.   * automatically.  The details of the growth policy are not specified.
# Line 118  Line 118 
118      /**      /**
119       * Create a <tt>PriorityQueue</tt> containing the elements in the specified       * Create a <tt>PriorityQueue</tt> containing the elements in the specified
120       * collection.  The priority queue has an initial capacity of 110% of the       * collection.  The priority queue has an initial capacity of 110% of the
121       * size of the specified collection (bounded by       * size of the specified collection or 1 if the collection is empty.
      * <tt>Integer.MAX_VALUE-1</tt>); or 1 if the collection is empty.  
122       * If the specified collection       * If the specified collection
123       * implements the {@link Sorted} interface, the priority queue will be       * implements the {@link Sorted} interface, the priority queue will be
124       * sorted according to the same comparator, or according to its elements'       * sorted according to the same comparator, or according to its elements'
# Line 145  Line 144 
144    
145          this.queue = new Object[initialCapacity + 1];          this.queue = new Object[initialCapacity + 1];
146    
         // FIXME: if c is larger than Integer.MAX_VALUE we'll  
         // overflow the array  
   
147          if (c instanceof Sorted) {          if (c instanceof Sorted) {
148              comparator = (Comparator<? super E>)((Sorted)c).comparator();              comparator = (Comparator<? super E>)((Sorted)c).comparator();
149          } else {          } else {
# Line 176  Line 172 
172          ++size;          ++size;
173    
174          // Grow backing store if necessary          // Grow backing store if necessary
         // FIXME: watch for overflow  
         // FIXME: what if we're full?  
175          while (size >= queue.length) {          while (size >= queue.length) {
176              Object[] newQueue = new Object[2 * queue.length];              Object[] newQueue = new Object[2 * queue.length];
177              System.arraycopy(queue, 0, newQueue, 0, queue.length);              System.arraycopy(queue, 0, newQueue, 0, queue.length);

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8