Why doesn't java.util.HashSet have a get(Object o) method?
问题 I've seen other questions about getting objects from Set 's based on index value and I understand why that is not possible. But I haven't been able to find a good explanation for why a get by object is not allowed so thought I would ask. HashSet is backed by a HashMap so getting an object from it should be pretty straightforward. As it is now, it appears I would have to iterate over each item in the HashSet and test for equality which seems unnecessary. I could just use a Map but I have no