summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic/ParallelMapFactory.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/generic/ParallelMapFactory.scala')
-rw-r--r--src/library/scala/collection/generic/ParallelMapFactory.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/library/scala/collection/generic/ParallelMapFactory.scala b/src/library/scala/collection/generic/ParallelMapFactory.scala
new file mode 100644
index 0000000000..8f779b4029
--- /dev/null
+++ b/src/library/scala/collection/generic/ParallelMapFactory.scala
@@ -0,0 +1,42 @@
+package scala.collection.generic
+
+
+
+import scala.collection.parallel.ParallelMap
+import scala.collection.parallel.ParallelMapLike
+import scala.collection.parallel.Combiner
+import scala.collection.mutable.Builder
+
+
+
+
+/** A template class for companion objects of `ParallelMap` and subclasses thereof.
+ * This class extends `TraversableFactory` and provides a set of operations to create `$Coll` objects.
+ *
+ * @define $coll parallel map
+ * @define $Coll ParallelMap
+ */
+abstract class ParallelMapFactory[CC[X, Y] <: ParallelMap[X, Y] with ParallelMapLike[X, Y, CC[X, Y], _]]
+extends MapFactory[CC]
+ with GenericParallelMapCompanion[CC] {
+
+ type MapColl = CC[_, _]
+
+ /** The default builder for $Coll objects.
+ * @tparam K the type of the keys
+ * @tparam V the type of the associated values
+ */
+ override def newBuilder[K, V]: Builder[(K, V), CC[K, V]] = newCombiner[K, V]
+
+ /** The default combiner for $Coll objects.
+ * @tparam K the type of the keys
+ * @tparam V the type of the associated values
+ */
+ def newCombiner[K, V]: Combiner[(K, V), CC[K, V]]
+
+ class CanCombineFromMap[K, V] extends CanCombineFrom[CC[_, _], (K, V), CC[K, V]] {
+ def apply(from: MapColl) = from.genericMapCombiner[K, V].asInstanceOf[Combiner[(K, V), CC[K, V]]]
+ def apply() = newCombiner[K, V]
+ }
+
+}