[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.40, Fri Sep 12 15:38:26 2003 UTC revision 1.41, Sat Sep 13 18:51:06 2003 UTC
# Line 8  Line 8 
8  package java.util;  package java.util;
9    
10  /**  /**
11   * An unbounded priority {@linkplain Queue queue} based on a priority heap.   * An unbounded priority {@linkplain Queue queue} based on a priority
12   * This queue orders elements according to an order specified at construction   * heap.  This queue orders elements according to an order specified
13   * time, which is specified in the same manner as {@link java.util.TreeSet}   * at construction time, which is specified either according to their
14   * and {@link java.util.TreeMap}: elements are ordered either according to   * <i>natural order</i> (see {@link Comparable}), or according to a
15   * their <i>natural order</i> (see {@link Comparable}), or according to a   * {@link java.util.Comparator}, depending on which constructor is
16   * {@link java.util.Comparator}, depending on which constructor is used.   * used. A priority queue does not permit <tt>null</tt> elements.
17   *   *
18   * <p>The <em>head</em> of this queue is the <em>least</em> element with   * <p>The <em>head</em> of this queue is the <em>least</em> element
19   * respect to the specified ordering.  If multiple elements are tied for least   * with respect to the specified ordering.  If multiple elements are
20   * value, the head is one of those elements. A priority queue does not permit   * tied for least value, the head is one of those elements -- ties are
21   * <tt>null</tt> elements.   * broken arbitrarily.  The {@link #remove()} and {@link #poll()}
22     * methods remove and return the head of the queue, and the {@link
23     * #element()} and {@link #peek()} methods return, but do not delete,
24     * the head of the queue.
25   *   *
26   * <p>The {@link #remove()} and {@link #poll()} methods remove and   * <p>A priority queue is unbounded, but has an internal
27   * return the head of the queue.   * <i>capacity</i> governing the size of an array used to store the
  *  
  * <p>The {@link #element()} and {@link #peek()} methods return, but do  
  * not delete, the head of the queue.  
  *  
  * <p>A priority queue is unbounded, but has a <i>capacity</i>.  The  
  * capacity is the size of the array used internally to store the  
28   * elements on the queue.  It is always at least as large as the queue   * elements on the queue.  It is always at least as large as the queue
29   * size.  As elements are added to a priority queue, its capacity   * size.  As elements are added to a priority queue, its capacity
30   * grows automatically.  The details of the growth policy are not   * grows automatically.  The details of the growth policy are not
31   * specified.   * specified.
32   *   *
33   * <p>The Iterator provided in method {@link #iterator()} is <em>not</em>   * <p>This class implements all of the <em>optional</em> methods of
34     * the {@link Collection} and {@link Iterator} interfaces.  The
35     * Iterator provided in method {@link #iterator()} is <em>not</em>
36   * guaranteed to traverse the elements of the PriorityQueue in any   * guaranteed to traverse the elements of the PriorityQueue in any
37   * particular order. If you need ordered traversal, consider using   * particular order. If you need ordered traversal, consider using
38   * <tt>Arrays.sort(pq.toArray())</tt>.   * <tt>Arrays.sort(pq.toArray())</tt>.
# Line 321  Line 320 
320       * to the priority queue's ordering.       * to the priority queue's ordering.
321       */       */
322      public boolean add(E o) {      public boolean add(E o) {
323          return super.add(o);          return offer(o);
324      }      }
325    
326    

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8