Proposal: Comparables.isCommutativelyComparable (original) (raw)
Martin Buchholz martinrb at google.com
Sun Jun 9 01:20:54 UTC 2013
- Previous message: Proposal: Comparables.isCommutativelyComparable
- Next message: Proposal: Comparables.isCommutativelyComparable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jun 8, 2013 at 8:50 AM, Doug Lea <dl at cs.oswego.edu> wrote:
But there's nothing about interface Comparable that forces this to be true. It would be weird but legal if both are of form, say, "class C implements Comparable".
The antisymmetric property prevents this from being legal.
"""The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)"""
Which means that you cannot compare them to each other.
- Previous message: Proposal: Comparables.isCommutativelyComparable
- Next message: Proposal: Comparables.isCommutativelyComparable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]