summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-03-09 16:17:21 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-03-09 16:17:21 +0000
commitcfeea7a25bd8358ab55d85afb541196dc32ac266 (patch)
treea3d8a72430d40a3d5af629f06608a4515f28cecb
parent9f964bcfd06810bbc73c375cee8adc15780e71d1 (diff)
downloadscala-cfeea7a25bd8358ab55d85afb541196dc32ac266.tar.gz
scala-cfeea7a25bd8358ab55d85afb541196dc32ac266.tar.bz2
scala-cfeea7a25bd8358ab55d85afb541196dc32ac266.zip
Fixes and closes #4328.
No review.
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 6b32a7c6b8..b51619e657 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -455,6 +455,18 @@ self =>
executeAndWaitResult(new Max(ord, parallelIterator) mapResult { _.get }).asInstanceOf[T]
}
+ override def maxBy[S](f: T => S)(implicit cmp: Ordering[S]): T = {
+ if (isEmpty) throw new UnsupportedOperationException("empty.maxBy")
+
+ reduce((x, y) => if (cmp.gteq(f(x), f(y))) x else y)
+ }
+
+ override def minBy[S](f: T => S)(implicit cmp: Ordering[S]): T = {
+ if (isEmpty) throw new UnsupportedOperationException("empty.maxBy")
+
+ reduce((x, y) => if (cmp.lteq(f(x), f(y))) x else y)
+ }
+
override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[Repr, S, That]): That = bf ifParallel { pbf =>
executeAndWaitResult(new Map[S, That](f, pbf, parallelIterator) mapResult { _.result })
} otherwise super.map(f)(bf)