O'Reilly logo

Learning Concurrent Programming in Scala by Aleksandar Prokopec

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required