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.95 by dl, Wed Mar 27 23:09:35 2013 UTC vs.
Revision 1.102 by jsr166, Wed Dec 31 07:54:13 2014 UTC

# Line 24 | Line 24
24   */
25  
26   package java.util;
27 +
28   import java.util.function.Consumer;
29   import java.util.stream.Stream;
29 import java.util.stream.Streams;
30  
31   /**
32   * An unbounded priority {@linkplain Queue queue} based on a priority heap.
# Line 66 | Line 66 | import java.util.stream.Streams;
66   * java.util.concurrent.PriorityBlockingQueue} class.
67   *
68   * <p>Implementation note: this implementation provides
69 < * O(log(n)) time for the enqueing and dequeing methods
69 > * O(log(n)) time for the enqueuing and dequeuing methods
70   * ({@code offer}, {@code poll}, {@code remove()} and {@code add});
71   * linear time for the {@code remove(Object)} and {@code contains(Object)}
72   * methods; and constant time for the retrieval methods
# Line 78 | Line 78 | import java.util.stream.Streams;
78   *
79   * @since 1.5
80   * @author Josh Bloch, Doug Lea
81 < * @param <E> the type of elements held in this collection
81 > * @param <E> the type of elements held in this queue
82   */
83   public class PriorityQueue<E> extends AbstractQueue<E>
84      implements java.io.Serializable {
# Line 100 | Line 100 | public class PriorityQueue<E> extends Ab
100      /**
101       * The number of elements in the priority queue.
102       */
103 <    private int size = 0;
103 >    private int size;
104  
105      /**
106       * The comparator, or null if priority queue uses elements'
# Line 394 | Line 394 | public class PriorityQueue<E> extends Ab
394       * @return {@code true} if this queue contains the specified element
395       */
396      public boolean contains(Object o) {
397 <        return indexOf(o) != -1;
397 >        return indexOf(o) >= 0;
398      }
399  
400      /**
# Line 477 | Line 477 | public class PriorityQueue<E> extends Ab
477           * Index (into queue array) of element to be returned by
478           * subsequent call to next.
479           */
480 <        private int cursor = 0;
480 >        private int cursor;
481  
482          /**
483           * Index of element returned by most recent call to next,
# Line 497 | Line 497 | public class PriorityQueue<E> extends Ab
497           * We expect that most iterations, even those involving removals,
498           * will not need to store elements in this field.
499           */
500 <        private ArrayDeque<E> forgetMeNot = null;
500 >        private ArrayDeque<E> forgetMeNot;
501  
502          /**
503           * Element returned by the most recent call to next iff that
504           * element was drawn from the forgetMeNot list.
505           */
506 <        private E lastRetElt = null;
506 >        private E lastRetElt;
507  
508          /**
509           * The modCount value that the iterator believes that the backing
# Line 744 | Line 744 | public class PriorityQueue<E> extends Ab
744       *             emitted (int), followed by all of its elements
745       *             (each an {@code Object}) in the proper order.
746       * @param s the stream
747 +     * @throws java.io.IOException if an I/O error occurs
748       */
749      private void writeObject(java.io.ObjectOutputStream s)
750          throws java.io.IOException {
# Line 763 | Line 764 | public class PriorityQueue<E> extends Ab
764       * (that is, deserializes it).
765       *
766       * @param s the stream
767 +     * @throws ClassNotFoundException if the class of a serialized object
768 +     *         could not be found
769 +     * @throws java.io.IOException if an I/O error occurs
770       */
771      private void readObject(java.io.ObjectInputStream s)
772          throws java.io.IOException, ClassNotFoundException {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines