Parallel collections were designed to provide a programming API similar to sequential Scala collections. Every sequential collection has a parallel counterpart and most operations have the same signature in both sequential and parallel collections. Still, there are some caveats when using parallel collections, and we will study them in this section.
Parallel collections use
splitters, represented with the
Splitter[T] type, in order to provide parallel operations. A splitter is a more advanced form of an iterator; in addition to the iterator's
hasNext methods, splitters define the
split method that divides the splitter
S into a sequence of splitters that traverse parts of
def split: Seq[Splitter[T]]
This method allows separate processors to traverse separate parts of the input collection. The
split method must be implemented efficiently, as this method is invoked many times during the execution of a parallel operation...