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 .