Parallel collections in Scala
It's obvious that if the number of elements in a collection is very large, then you would want to minimize the time it takes to manipulate the collection data. That's where breaking down the tasks and executing them parallel is an option, and a good one. Scala provides parallelism in the form of parallel collections, which works like a charm in scenarios where we have to deal with a big chunk of data. The good thing is that our  par
 method can easily convert a normal sequential collection to its parallel counterpart implicitly, and the map
,fold
, and filter
 methods work great with parallel collections as well.
Understanding the architecture of parallel collections, or how these work on JVM, is out of the scope of this book. We'll keep our discussion limited to concrete implementations of parallel collections, and how we can use them in Scala. If you're into understanding parallel collections, Scala's documentation gives a brief overview at http://docs.scala-lang...