Skip to content

Commit

Permalink
Extra assertions on Weighted
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Jun 27, 2018
1 parent c59faf5 commit 57cd6fc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/gr/james/sampling/Weighted.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public Weighted(T object, double weight) {
public int compareTo(Weighted<T> o) {
final int c = Double.compare(weight, o.weight);
if (c == 0) {
assert (Integer.compare(System.identityHashCode(this), System.identityHashCode(o)) == 0) == (this.equals(o));
return Integer.compare(System.identityHashCode(this), System.identityHashCode(o));
} else {
assert !this.equals(o);
return c;
}
}
Expand All @@ -65,6 +67,7 @@ public int compareTo(Weighted<T> o) {
*/
@Override
public boolean equals(Object obj) {
assert !super.equals(obj) || super.hashCode() == obj.hashCode();
return super.equals(obj);
}

Expand Down

0 comments on commit 57cd6fc

Please sign in to comment.