Partial ordered Comparator

后端 未结 6 1488
灰色年华
灰色年华 2020-12-18 22:35

How to implement java.util.Comparator that orders its elements according to a partial order relation?

For example given a partial order relation a

6条回答
  •  感动是毒
    2020-12-18 23:03

    When one item is neither "before" nor "after" another, instead of returning a comparison of the hashcode, just return 0. The result will be "total ordering" and "arbitrary" ordering of coincident items.

提交回复
热议问题