Java HashSet with a custom equality criteria? [duplicate]
问题 This question already has answers here : Is it possible in java make something like Comparator but for implementing custom equals() and hashCode() (7 answers) Closed 6 years ago . I was looking for something akin to the Java TreeSet's ability to receive a custom comparator at instantiation time, so I needed not to use the object's default equality (and hash code) criteria. The closest I could come up with was to wrap my objects in a private custom class, but that seems hacky :( This ends up