diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-05-25 05:06:01 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-05-25 05:06:01 -0700 |
commit | e506e8a2ca52ebc31d31dc0c82b6f266a0675466 (patch) | |
tree | d254aa8624e2c3e197dbd5b994294fe0d78372df /src/library | |
parent | 09e8361a5c485e52b40f9f863469d5830f1cfabf (diff) | |
parent | 5ae842c6729a34806cc04b891ad1fec03f2ebcd8 (diff) | |
download | scala-e506e8a2ca52ebc31d31dc0c82b6f266a0675466.tar.gz scala-e506e8a2ca52ebc31d31dc0c82b6f266a0675466.tar.bz2 scala-e506e8a2ca52ebc31d31dc0c82b6f266a0675466.zip |
Merge pull request #621 from axel22/issue/5085b
Fixes SI-5085 and SI-4833.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/mutable/PriorityQueue.scala | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 12dee45bae..af55a01ed6 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -161,10 +161,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) */ def clear(): Unit = { resarr.p_size0 = 1 } - /** Returns an iterator which yields all the elements of the priority - * queue in descending priority order. + /** Returns an iterator which yields all the elements. * - * @return an iterator over all elements sorted in descending order. + * Note: The order of elements returned is undefined. + * If you want to traverse the elements in priority queue + * order, use `clone().dequeueAll.iterator`. + * + * @return an iterator over all the elements. */ override def iterator: Iterator[A] = new AbstractIterator[A] { private var i = 1 @@ -176,7 +179,6 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) } } - /** Returns the reverse of this queue. The priority queue that gets * returned will have an inversed ordering - if for some elements * `x` and `y` the original queue's ordering @@ -198,6 +200,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) revq } + /** Returns an iterator which yields all the elements in the reverse order + * than that returned by the method `iterator`. + * + * Note: The order of elements returned is undefined. + * + * @return an iterator over all elements sorted in descending order. + */ def reverseIterator: Iterator[A] = new AbstractIterator[A] { private var i = resarr.p_size0 - 1 def hasNext: Boolean = i >= 1 @@ -217,6 +226,8 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) throw new UnsupportedOperationException("unsuitable as hash key") /** Returns a regular queue containing the same elements. + * + * Note: the order of elements is undefined. */ def toQueue: Queue[A] = new Queue[A] ++= this.iterator @@ -225,6 +236,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) * @return the string representation of this queue. */ override def toString() = toList.mkString("PriorityQueue(", ", ", ")") + + /** Converts this $coll to a list. + * + * Note: the order of elements is undefined. + * + * @return a list containing all elements of this $coll. + */ override def toList = this.iterator.toList /** This method clones the priority queue. |