Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Commit 626ee80

Browse files
author
prokopec
committed
Fixes and closes #4328.
No review. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@24425 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
1 parent 2934866 commit 626ee80

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/library/scala/collection/parallel/ParIterableLike.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ self =>
455455
executeAndWaitResult(new Max(ord, parallelIterator) mapResult { _.get }).asInstanceOf[T]
456456
}
457457

458+
override def maxBy[S](f: T => S)(implicit cmp: Ordering[S]): T = {
459+
if (isEmpty) throw new UnsupportedOperationException("empty.maxBy")
460+
461+
reduce((x, y) => if (cmp.gteq(f(x), f(y))) x else y)
462+
}
463+
464+
override def minBy[S](f: T => S)(implicit cmp: Ordering[S]): T = {
465+
if (isEmpty) throw new UnsupportedOperationException("empty.maxBy")
466+
467+
reduce((x, y) => if (cmp.lteq(f(x), f(y))) x else y)
468+
}
469+
458470
override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[Repr, S, That]): That = bf ifParallel { pbf =>
459471
executeAndWaitResult(new Map[S, That](f, pbf, parallelIterator) mapResult { _.result })
460472
} otherwise super.map(f)(bf)

src/library/scala/collection/parallel/immutable/ParRange.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import scala.collection.parallel.ParIterableIterator
2828
*
2929
* @author Aleksandar Prokopec
3030
* @since 2.9
31-
*
31+
*
3232
* @define Coll immutable.ParRange
3333
* @define coll immutable parallel range
3434
*/

0 commit comments

Comments
 (0)