Implementing custom parallel collections

Parallel collections in the Scala standard library are sufficient for most tasks, but in some cases we want to add parallel operations to our own collections. The Java String class does not have a direct parallel counterpart in the parallel collections framework. In this section, we will study how to implement a custom ParString class that supports parallel operations. We will then use our custom parallel collection class in several example programs.

The first step to implementing a custom parallel collection is to extend the correct parallel collection trait. A parallel string is a sequence of characters, so we need to extend the ParSeq trait with the Char type argument. Once a string is created, it can ...

Get Learning Concurrent Programming in Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.