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.106 by jsr166, Tue Jun 16 23:06:01 2015 UTC vs.
Revision 1.111 by jsr166, Wed Nov 23 20:36:31 2016 UTC

# Line 54 | Line 54 | import java.util.function.Consumer;
54   * <p>This class and its iterator implement all of the
55   * <em>optional</em> methods of the {@link Collection} and {@link
56   * Iterator} interfaces.  The Iterator provided in method {@link
57 < * #iterator()} is <em>not</em> guaranteed to traverse the elements of
57 > * #iterator()} and the Spliterator provided in method {@link #spliterator()}
58 > * are <em>not</em> guaranteed to traverse the elements of
59   * the priority queue in any particular order. If you need ordered
60   * traversal, consider using {@code Arrays.sort(pq.toArray())}.
61   *
# Line 99 | Line 100 | public class PriorityQueue<E> extends Ab
100      /**
101       * The number of elements in the priority queue.
102       */
103 <    private int size;
103 >    int size;
104  
105      /**
106       * The comparator, or null if priority queue uses elements'
# Line 337 | Line 338 | public class PriorityQueue<E> extends Ab
338          int i = size;
339          if (i >= queue.length)
340              grow(i + 1);
341 +        siftUp(i, e);
342          size = i + 1;
341        if (i == 0)
342            queue[0] = e;
343        else
344            siftUp(i, e);
343          return true;
344      }
345  
# Line 609 | Line 607 | public class PriorityQueue<E> extends Ab
607       * avoid missing traversing elements.
608       */
609      @SuppressWarnings("unchecked")
610 <    private E removeAt(int i) {
610 >    E removeAt(int i) {
611          // assert i >= 0 && i < size;
612          modCount++;
613          int s = --size;
# Line 752 | Line 750 | public class PriorityQueue<E> extends Ab
750      /**
751       * Saves this queue to a stream (that is, serializes it).
752       *
753 +     * @param s the stream
754 +     * @throws java.io.IOException if an I/O error occurs
755       * @serialData The length of the array backing the instance is
756       *             emitted (int), followed by all of its elements
757       *             (each an {@code Object}) in the proper order.
758     * @param s the stream
759     * @throws java.io.IOException if an I/O error occurs
758       */
759      private void writeObject(java.io.ObjectOutputStream s)
760          throws java.io.IOException {
# Line 802 | Line 800 | public class PriorityQueue<E> extends Ab
800      /**
801       * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
802       * and <em>fail-fast</em> {@link Spliterator} over the elements in this
803 <     * queue.
803 >     * queue. The spliterator does not traverse elements in any particular order
804 >     * (the {@link Spliterator#ORDERED ORDERED} characteristic is not reported).
805       *
806       * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
807       * {@link Spliterator#SUBSIZED}, and {@link Spliterator#NONNULL}.
# Line 826 | Line 825 | public class PriorityQueue<E> extends Ab
825          private int fence;            // -1 until first use
826          private int expectedModCount; // initialized when fence set
827  
828 <        /** Creates new spliterator covering the given range */
828 >        /** Creates new spliterator covering the given range. */
829          PriorityQueueSpliterator(PriorityQueue<E> pq, int origin, int fence,
830 <                             int expectedModCount) {
830 >                                 int expectedModCount) {
831              this.pq = pq;
832              this.index = origin;
833              this.fence = fence;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines