title: HashSet vs ArrayList contains performance
body: <p>When processing large amounts of data I often find myself doing the following:</p>
  
  <pre><code>HashSet&lt;String&gt; set = new HashSet&lt;String&gt; ();
  //Adding elements to the set
  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt; (set);
  </code></pre>
  
  <p>Something like "dumping" the contents of the set in the list. I usually do this since the elements I add often contain duplicates I want to remove, and this seems like an easy way to remove them.</p>
  
  <p>With only that objective in mind (avoiding duplicates) I could also write:</p>
  
  <pre><code>ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt; ();
  // Processing here
  if (! list.contains(element)) list.add(element);
  //More processing here
  </code></pre>
  
  <p>And thus no need for "dumping" the set into the list. However, I'd be doing a small check before inserting each element (which I'm assuming HashSet does as well) </p>
  
  <p>Is any of the two possibilities clearly more efficient?</p>