--- jsr166/src/main/java/util/PriorityQueue.java 2010/09/05 21:32:19 1.71
+++ jsr166/src/main/java/util/PriorityQueue.java 2012/12/15 22:26:29 1.79
@@ -56,14 +56,14 @@ package java.util;
* the priority queue in any particular order. If you need ordered
* traversal, consider using {@code Arrays.sort(pq.toArray())}.
*
- *
Note that this implementation is not synchronized.
+ *
Note that this implementation is not synchronized.
* Multiple threads should not access a {@code PriorityQueue}
* instance concurrently if any of the threads modifies the queue.
* Instead, use the thread-safe {@link
* java.util.concurrent.PriorityBlockingQueue} class.
*
*
Implementation note: this implementation provides
- * O(log(n)) time for the enqueing and dequeing methods
+ * O(log(n)) time for the enqueuing and dequeuing methods
* ({@code offer}, {@code poll}, {@code remove()} and {@code add});
* linear time for the {@code remove(Object)} and {@code contains(Object)}
* methods; and constant time for the retrieval methods
@@ -77,6 +77,7 @@ package java.util;
* @author Josh Bloch, Doug Lea
* @param the type of elements held in this collection
*/
+@SuppressWarnings("unchecked")
public class PriorityQueue extends AbstractQueue
implements java.io.Serializable {
@@ -331,9 +332,7 @@ public class PriorityQueue extends Ab
}
public E peek() {
- if (size == 0)
- return null;
- return (E) queue[0];
+ return (size == 0) ? null : (E) queue[0];
}
private int indexOf(Object o) {
@@ -434,8 +433,7 @@ public class PriorityQueue extends Ab
* The following code can be used to dump the queue into a newly
* allocated array of String:
*
- *
- * String[] y = x.toArray(new String[0]);
+ * {@code String[] y = x.toArray(new String[0]);}
*
* Note that toArray(new Object[0]) is identical in function to
* toArray().
@@ -592,7 +590,7 @@ public class PriorityQueue extends Ab
* avoid missing traversing elements.
*/
private E removeAt(int i) {
- assert i >= 0 && i < size;
+ // assert i >= 0 && i < size;
modCount++;
int s = --size;
if (s == i) // removed last element
@@ -727,16 +725,14 @@ public class PriorityQueue extends Ab
}
/**
- * Saves the state of the instance to a stream (that
- * is, serializes it).
+ * Saves this queue to a stream (that is, serializes it).
*
* @serialData The length of the array backing the instance is
* emitted (int), followed by all of its elements
* (each an {@code Object}) in the proper order.
- * @param s the stream
*/
private void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException{
+ throws java.io.IOException {
// Write out element count, and any hidden stuff
s.defaultWriteObject();
@@ -749,10 +745,7 @@ public class PriorityQueue extends Ab
}
/**
- * Reconstitutes the {@code PriorityQueue} instance from a stream
- * (that is, deserializes it).
- *
- * @param s the stream
+ * Reconstitutes this queue from a stream (that is, deserializes it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {