diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-07-28 14:49:28 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-07-28 14:49:28 +0000 |
commit | 5aeca8a716c2ef31f2e73d0bb3f1767b64a8708b (patch) | |
tree | b7aed6998599fab5d8319df9819e316ae4d294fb /src/library | |
parent | bc0ed202b6006ee8e3ccdf71b800ed99246437a8 (diff) | |
download | scala-5aeca8a716c2ef31f2e73d0bb3f1767b64a8708b.tar.gz scala-5aeca8a716c2ef31f2e73d0bb3f1767b64a8708b.tar.bz2 scala-5aeca8a716c2ef31f2e73d0bb3f1767b64a8708b.zip |
Fixes a priority queue issue. No review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/mutable/PriorityQueue.scala | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index b1ca5fde3c..397fc5e30b 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -59,8 +59,16 @@ class PriorityQueue[A](implicit ord: Ordering[A]) override def isEmpty: Boolean = resarr.p_size0 < 2 override def repr = this - // hey foreach, our 0th element doesn't exist - override def foreach[U](f: A => U) { + /** A version of `foreach` that traverses elements in an unspecified order. + * + * This method is faster than `foreach` as it does not copy the heap to + * traverse it. + * + * @tparam U the return type of `f` + * @param f the function to be applied at each element, return value ignored + */ + def foreachUnordered[U](f: A => U) { + // hey foreach, our 0th element doesn't exist var i = 1 while (i < resarr.p_size0) { f(toA(resarr.p_array(i))) @@ -285,4 +293,4 @@ class PriorityQueue[A](implicit ord: Ordering[A]) // def empty[A](implicit ord: Ordering[A]): PriorityQueue[A] = new PriorityQueue[A](ord) // implicit def canBuildFrom[A](implicit ord: Ordering[A]): CanBuildFrom[Coll, A, PriorityQueue] = // } -//
\ No newline at end of file +// |