title: What is the best way to create map in parallel with scala?
body: <p>Suppose I have a collection which should be converted to Map, but not in one to one fashion like map method.</p>
  
  <pre><code>var map = collection.mutable.HashMap()
  for (p &lt;- dataList.par) {
    if(cond1(p)) {
      map += (p, true)
    } else {
      // do nothing
    }
  }
  </code></pre>
  
  <p>I've come up with several solutions and want to know what is best.</p>
  
  <ol>
  <li><p><code>map.synchronize { map += (p, true) }</code></p></li>
  <li><p>use actor to update map. But I dont know how to wait till all actors task are completed</p></li>
  <li><code>yield Some(p) or None</code> and then run <code>foreach { case Some(p) =&gt; map += (p, true)}</code>. But I don't know how to make it sequential if first iterator is from parallel collections.</li>
  </ol>