title: Stand multi-threaded approach to build the set of all elements in an array?
body: <p>I have an array of elements I want to hash (it's a templated array; or a vector if you like), and an empty hash table. I have a CPU with several cores (and hyperthreading), and want to utilize it as best possible to insert all array elements into the set. Is there code in the STL (or in Boost or some other free library) which does this?</p>
  
  <p>I realize some trivial solutions are:</p>
  
  <ol>
  <li>Use a concurrent/thread-safe set (e.g. hash-backed), and just have each thread insert a section of the array.</li>
  <li>Have each thread create its own set, then repeatedly compute set unions.</li>
  </ol>
  
  <p>But the point is I would rather not write my own but go for commonly-used code. <strong>Edit</strong> also, I want a solution which does not require me to use some specific thread management/pooling system, but which I can just use with arbitrary threads of mine.</p>
  
  <p><strong>Notes:</strong></p>
  
  <ul>
  <li>Needless to say, the set insertion doesn't insert duplicate copies.</li>
  <li>The array may have duplicates (in fact, I expect the number of set elements to be less than 1% of the array length - but cannot assume this always to be the case).</li>
  <li>The set does not need to support element removal, or it can be slow etc.</li>
  </ul>