Notes on TreeSet and HashSet
The underlying data structure for a TreeSet is TreeMap. We know this because if we add items to a TreeSet that do not implement Comparable we get a run time error message for TreeMap.compare()
Therefore we can only have Objects that implement the Comparable in a TreeSet. Objects added to HashSet do not have to implement the Comparable.
The underlying data structure of a HashSet must be a list - but what type?
TreeMap t = new TreeMap();
String s = t.get(new Person("Fred"));
The above will work for a TreeMap but it won't work for HashMap because the HashMap must use the address of the object to index it and here we have a new address.
The TreeMap searches for the object by the key value and if the Object resolves to the same key value it will work even though it didn't really find the same Object.