title: How to de-dupe a List of Objects?
body: <p>A <code>Rec</code> object has a member variable called <code>tag</code> which is a <code>String</code>.</p>
  
  <p>If I have a <code>List</code> of <code>Rec</code>s, how could I de-dupe the list based on the <code>tag</code> member variable?</p>
  
  <p>I just need to make sure that the <code>List</code> contains only one <code>Rec</code> with each <code>tag</code> value.</p>
  
  <p>Something like the following, but I'm not sure what's the best algorithm to keep track counts, etc:</p>
  
  <pre><code>private List&lt;Rec&gt; deDupe(List&lt;Rec&gt; recs) {
  
      for(Rec rec : recs) {
  
           // How to check whether rec.tag exists in another Rec in this List
           // and delete any duplicates from the List before returning it to
           // the calling method?
  
      }
  
      return recs;
  
  }
  </code></pre>