title: Equals and Comparable with Sets
body: <p>I posted some code <a href="https://stackoverflow.com/a/12748832/823393">here</a> which correctly solved a problem the poster had. OP wanted to remove duplicates and bring certain special items to the top of a list. I used a <code>TreeSet</code> with a special <code>Comparable</code> class which wrapped the <code>Locale</code> they were working with to achieve what they wanted.</p>
  
  <p>I then got to thinking ... as you do ... that I was eliminating duplicates by returning <code>0</code> from the <code>compareTo</code> method, not by returning <code>true</code> from an <code>equals</code> implementation as one would need to do to correctly indicate a duplicate in a <code>Set</code> (from the <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Set.html" rel="noreferrer">definition</a> of a <code>Set</code>).</p>
  
  <p>I have no objection to using this technique but am I using what might be considered an <em>undocumented feature</em>? Am I safe to assume that doing this kind of thing going forward will continue to work?</p>