diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-03-09 16:17:21 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-03-09 16:17:21 +0000 |
commit | cfeea7a25bd8358ab55d85afb541196dc32ac266 (patch) | |
tree | a3d8a72430d40a3d5af629f06608a4515f28cecb | |
parent | 9f964bcfd06810bbc73c375cee8adc15780e71d1 (diff) | |
download | scala-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.scala | 12 |
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) |