IEqualityComparer interface in Java

后端 未结 4 1682
野性不改
野性不改 2021-02-13 12:27

More specifically I want an interface to compare objects which can be only compared for equality [e.g. complex numbers] but don\'t have total order on them. It should have [Not

4条回答
  •  轮回少年
    2021-02-13 12:38

    The type you want is Guava's Equivalence. However, you may be disappointed, as in Java Collection and Map are fairly rigidly specified in terms of Object.equals, and you will not find implementations of those in Guava that use an alternate equivalence. You can, however, simulate that behavior a bit using myEquivalence.wrap(myObject).

提交回复
热议问题