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.94 by dl, Wed Mar 13 12:38:56 2013 UTC vs.
Revision 1.105 by jsr166, Fri Feb 27 19:01:11 2015 UTC

# Line 24 | Line 24
24   */
25  
26   package java.util;
27 +
28   import java.util.function.Consumer;
28 import java.util.stream.Stream;
29 import java.util.stream.Streams;
29  
30   /**
31   * An unbounded priority {@linkplain Queue queue} based on a priority heap.
# Line 66 | Line 65 | import java.util.stream.Streams;
65   * java.util.concurrent.PriorityBlockingQueue} class.
66   *
67   * <p>Implementation note: this implementation provides
68 < * O(log(n)) time for the enqueing and dequeing methods
68 > * O(log(n)) time for the enqueuing and dequeuing methods
69   * ({@code offer}, {@code poll}, {@code remove()} and {@code add});
70   * linear time for the {@code remove(Object)} and {@code contains(Object)}
71   * methods; and constant time for the retrieval methods
# Line 78 | Line 77 | import java.util.stream.Streams;
77   *
78   * @since 1.5
79   * @author Josh Bloch, Doug Lea
80 < * @param <E> the type of elements held in this collection
80 > * @param <E> the type of elements held in this queue
81   */
82   public class PriorityQueue<E> extends AbstractQueue<E>
83      implements java.io.Serializable {
# Line 100 | Line 99 | public class PriorityQueue<E> extends Ab
99      /**
100       * The number of elements in the priority queue.
101       */
102 <    private int size = 0;
102 >    private int size;
103  
104      /**
105       * The comparator, or null if priority queue uses elements'
# Line 112 | Line 111 | public class PriorityQueue<E> extends Ab
111       * The number of times this priority queue has been
112       * <i>structurally modified</i>.  See AbstractList for gory details.
113       */
114 <    transient int modCount = 0; // non-private to simplify nested class access
114 >    transient int modCount;     // non-private for nested class access
115  
116      /**
117       * Creates a {@code PriorityQueue} with the default initial
# Line 394 | Line 393 | public class PriorityQueue<E> extends Ab
393       * @return {@code true} if this queue contains the specified element
394       */
395      public boolean contains(Object o) {
396 <        return indexOf(o) != -1;
396 >        return indexOf(o) >= 0;
397      }
398  
399      /**
# Line 436 | Line 435 | public class PriorityQueue<E> extends Ab
435       * The following code can be used to dump the queue into a newly
436       * allocated array of {@code String}:
437       *
438 <     *  <pre> {@code String[] y = x.toArray(new String[0]);}</pre>
438 >     * <pre> {@code String[] y = x.toArray(new String[0]);}</pre>
439       *
440       * Note that {@code toArray(new Object[0])} is identical in function to
441       * {@code toArray()}.
# Line 477 | Line 476 | public class PriorityQueue<E> extends Ab
476           * Index (into queue array) of element to be returned by
477           * subsequent call to next.
478           */
479 <        private int cursor = 0;
479 >        private int cursor;
480  
481          /**
482           * Index of element returned by most recent call to next,
# Line 497 | Line 496 | public class PriorityQueue<E> extends Ab
496           * We expect that most iterations, even those involving removals,
497           * will not need to store elements in this field.
498           */
499 <        private ArrayDeque<E> forgetMeNot = null;
499 >        private ArrayDeque<E> forgetMeNot;
500  
501          /**
502           * Element returned by the most recent call to next iff that
503           * element was drawn from the forgetMeNot list.
504           */
505 <        private E lastRetElt = null;
505 >        private E lastRetElt;
506  
507          /**
508           * The modCount value that the iterator believes that the backing
# Line 744 | Line 743 | public class PriorityQueue<E> extends Ab
743       *             emitted (int), followed by all of its elements
744       *             (each an {@code Object}) in the proper order.
745       * @param s the stream
746 +     * @throws java.io.IOException if an I/O error occurs
747       */
748      private void writeObject(java.io.ObjectOutputStream s)
749          throws java.io.IOException {
# Line 763 | Line 763 | public class PriorityQueue<E> extends Ab
763       * (that is, deserializes it).
764       *
765       * @param s the stream
766 +     * @throws ClassNotFoundException if the class of a serialized object
767 +     *         could not be found
768 +     * @throws java.io.IOException if an I/O error occurs
769       */
770      private void readObject(java.io.ObjectInputStream s)
771          throws java.io.IOException, ClassNotFoundException {
# Line 823 | Line 826 | public class PriorityQueue<E> extends Ab
826          }
827  
828          @SuppressWarnings("unchecked")
829 <        public void forEach(Consumer<? super E> action) {
829 >        public void forEachRemaining(Consumer<? super E> action) {
830              int i, hi, mc; // hoist accesses and checks from loop
831              PriorityQueue<E> q; Object[] a;
832              if (action == null)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines