Hi,
Scala parallel collections docs and MOOC mention a .remaining method on Splitter and a .splitter method on collections returning a Splitter:
|
* All of the parallel operations are implemented as tasks within this trait. Tasks rely |
|
* on the concept of splitters, which extend iterators. Every parallel collection defines: |
|
* |
|
* {{{ |
|
* def splitter: IterableSplitter[T] |
|
* }}} |
|
* |
|
* which returns an instance of `IterableSplitter[T]`, which is a subtype of `Splitter[T]`. |
|
* Splitters have a method `remaining` to check the remaining number of elements, |
|
* and method `split` which is defined by splitters. Method `split` divides the splitters |
|
* iterate over into disjunct subsets: |
In practice, .remaining is actually defined on IterableSplitter:
|
trait IterableSplitter[+T] |
And the .splitter method is package-private:
|
protected[parallel] def splitter: IterableSplitter[T] |
Why is that?
Is there a way to obtain an IterableSplitter from a collection using the public API?
In particular, a slide of the MOOC suggests this implementation of .fold on a Splitter:

How could I use it in practice, say on a ParVector?
Hi,
Scala parallel collections docs and MOOC mention a
.remainingmethod onSplitterand a.splittermethod on collections returning aSplitter:scala-parallel-collections/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala
Lines 48 to 58 in 7bc6f6e
In practice,
.remainingis actually defined onIterableSplitter:scala-parallel-collections/core/src/main/scala/scala/collection/parallel/RemainsIterator.scala
Line 366 in 7bc6f6e
And the
.splittermethod is package-private:scala-parallel-collections/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala
Line 233 in 7bc6f6e
Why is that?
Is there a way to obtain an
IterableSplitterfrom a collection using the public API?In particular, a slide of the MOOC suggests this implementation of
.foldon aSplitter:How could I use it in practice, say on a
ParVector?