Using a HashSet

The best way to describe a HashSet is by describing how it's implemented: HashMap<K, ()>. It's just a HashMap without any values!

The two best reasons to choose a HashSet are:

  • You don't want to deal with duplicate values at all, as it doesn't even include them.
  • You plan on doing a lot (and I mean a lot) of item lookup - that is the question, Does my collection contain this particular item?. In a vector, this is done in , while a HashSet can do it in .
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.6.243