summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2015-09-02 18:28:51 -0400
committerSeth Tisue <seth@tisue.net>2015-09-02 18:28:51 -0400
commit7d2c0b354e59c61316bc118a57fa8584ebb523f8 (patch)
tree276323d67c515ff1e1b9c6a6e133e50077fab5c8 /src/library
parent1e47a730a9fbe7d4f465bb241272169cfefa14e6 (diff)
parent117ea7f5aaa42d19b67fc6d5bd4ec330af43f475 (diff)
downloadscala-7d2c0b354e59c61316bc118a57fa8584ebb523f8.tar.gz
scala-7d2c0b354e59c61316bc118a57fa8584ebb523f8.tar.bz2
scala-7d2c0b354e59c61316bc118a57fa8584ebb523f8.zip
Merge pull request #4715 from Ichoran/issue/9424
SI-9424 Clarify behavior of PriorityQueue toString
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index d3c4161e3b..2562f60355 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -18,8 +18,19 @@ import generic._
*
* Only the `dequeue` and `dequeueAll` methods will return methods in priority
* order (while removing elements from the heap). Standard collection methods
- * including `drop` and `iterator` will remove or traverse the heap in whichever
- * order seems most convenient.
+ * including `drop`, `iterator`, and `toString` will remove or traverse the heap
+ * in whichever order seems most convenient.
+ *
+ * Therefore, printing a `PriorityQueue` will not reveal the priority order of
+ * the elements, though the highest-priority element will be printed first. To
+ * print the elements in order, one must duplicate the `PriorityQueue` (by using
+ * `clone`, for instance) and then dequeue them:
+ *
+ * @example {{{
+ * val pq = collection.mutable.PriorityQueue(1, 2, 5, 3, 7)
+ * println(pq) // elements probably not in order
+ * println(pq.clone.dequeueAll) // prints Vector(7, 5, 3, 2, 1)
+ * }}}
*
* @tparam A type of the elements in this priority queue.
* @param ord implicit ordering used to compare the elements of type `A`.