--- jsr166/src/main/java/util/PriorityQueue.java 2003/08/12 11:11:58 1.27 +++ jsr166/src/main/java/util/PriorityQueue.java 2003/08/24 23:31:53 1.29 @@ -28,6 +28,18 @@ * elements are added to a priority queue, its capacity grows * automatically. The details of the growth policy are not specified. * + *

The Iterator provided in method {@link #iterator()} is not + * guaranteed to traverse the elements of the PriorityQueue in any + * particular order. If you need ordered traversal, consider using + * Arrays.sort(pq.toArray()). + * + *

Note that this implementation is not synchronized. + * Multiple threads should not access a PriorityQueue + * instance concurrently if any of the threads modifies the list + * structurally. Instead, use the thread-safe {@link + * java.util.concurrent.BlockingPriorityQueue} class. + * + * *

Implementation note: this implementation provides O(log(n)) time * for the insertion methods (offer, poll, * remove() and add) methods; linear time for the @@ -177,7 +189,8 @@ public class PriorityQueue extends Ab public PriorityQueue(Collection c) { initializeArray(c); if (c instanceof SortedSet) { - SortedSet s = (SortedSet) c; + // @fixme double-cast workaround for compiler + SortedSet s = (SortedSet) (SortedSet)c; comparator = (Comparator)s.comparator(); fillFromSorted(s); } else if (c instanceof PriorityQueue) {