Why doesn't java.util.HashSet have a get(Object o) method?

后端 未结 11 2199
暖寄归人
暖寄归人 2020-12-07 18:39

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

11条回答
  •  一整个雨季
    2020-12-07 19:02

    I've got the same problem as the thread author and I've got a real reason why a Set should have a get method: I overwrote equals of e.g. X, the content of the set Set and so the contained object is not necessarily the same as the checked one. In my scenario I'll remove semantic doubles in an other collection and enrich the "original" with some relations of the "double" so I need the "original" to be able to drop the double.

提交回复
热议问题