title: why it is better to convert hashset to treeset then working directly with treeset
body: <p>In many places in the web including sun website, the following sentence appear:</p>
  
  <blockquote>
    <p>It generally faster to preform actions
    on <code>hashSet</code> and then convert the
    <code>hashset</code> to <code>treeset</code>.</p>
  </blockquote>
  
  <p>well, i'm a little bit confused, thats correct that add element in <code>hashset</code> is <code>o(1)</code> and adding object in <code>treeset</code> (black &amp; red tree) is <code>o(logn)</code> but when i convert the hashset to the treeset i need to sort my data which is <code>o(nlogn)</code> so why it is faster to work with <code>hashset</code> and then convert it to <code>treeset</code>? i know that if you preform remove or existing element so there is a diffrence between hash and tree but i don't think it is the factor that sun refer to (at least i hope so since it looks like a very small thing) another thing is the <code>hashcode</code> methods can be not so good and then adding elements to the hash will not be <code>o(1)</code> or the <code>hashcode</code> method can be complicated. so generally i don't understand the sentence. can anyone help me?</p>