-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi,
Scala parallel collections docs and MOOC mention a .remaining method on Splitter and a .splitter method on collections returning a Splitter:
scala-parallel-collections/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala
Lines 48 to 58 in 7bc6f6e
| * 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:
scala-parallel-collections/core/src/main/scala/scala/collection/parallel/RemainsIterator.scala
Line 366 in 7bc6f6e
| trait IterableSplitter[+T] |
And the .splitter method is package-private:
scala-parallel-collections/core/src/main/scala/scala/collection/parallel/ParIterableLike.scala
Line 233 in 7bc6f6e
| 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?
