Every sequential collection can be converted to its parallel variant
using the par
method. Certain sequential collections have a
direct parallel counterpart. For these collections the conversion is
efficient– it occurs in constant time, since both the sequential and
the parallel collection have the same data-structural representation
(one exception is mutable hash maps and hash sets which are slightly
more expensive to convert the first time par
is called, but
subsequent invocations of par
take constant time). It should be
noted that for mutable collections, changes in the sequential collection are
visible in its parallel counterpart if they share the underlying data-structure.
This is a companion discussion topic for the original entry at http://docs.scala-lang.org//overviews/parallel-collections/conversions