From 7c3bbfa03a282cf9463d03bbbcedf1203b49338b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Wed, 19 Nov 2014 12:39:39 +0000 Subject: [PATCH] - Fixed the compareTo implementation in BasicCell --- src/fr/inrialpes/exmo/align/impl/BasicCell.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fr/inrialpes/exmo/align/impl/BasicCell.java b/src/fr/inrialpes/exmo/align/impl/BasicCell.java index 441291c3..6e62b89f 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicCell.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicCell.java @@ -99,8 +99,12 @@ public class BasicCell implements Cell, Comparable<Cell>, Extensible { result = relation.compareTo( ((BasicCell)c).getRelation() ); return result; // compatible with equals! */ + // same strength if ( equals( c ) ) return 0; // compatible with equals! - else return 1; // arbitrary order + // Now: if they are different, we do not want to say that they are equal + // But the compareTo contract says that the resut should be compatible + if ( hashCode() > c.hashCode() ) return 1; + else return -1; // (hoping hashCode will be different in all cases) } public String getId(){ return id; }; -- GitLab