Fixed findbugs warning.

When defining compareTo, we should also define equals and hashcode.
This commit is contained in:
Luc Maisonobe 2015-11-03 10:57:42 +01:00
parent 3f68627209
commit 1130658baf
1 changed files with 19 additions and 2 deletions

View File

@ -17,11 +17,11 @@
package org.apache.commons.math4.ml.neuralnet; package org.apache.commons.math4.ml.neuralnet;
import java.util.HashMap; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import org.apache.commons.math4.exception.NoDataException; import org.apache.commons.math4.exception.NoDataException;
import org.apache.commons.math4.ml.distance.DistanceMeasure; import org.apache.commons.math4.ml.distance.DistanceMeasure;
@ -322,5 +322,22 @@ public class MapUtils {
public int compareTo(PairNeuronDouble other) { public int compareTo(PairNeuronDouble other) {
return Double.compare(this.value, other.value); return Double.compare(this.value, other.value);
} }
/** {@inheritDoc} */
@Override
public boolean equals(Object other) {
if (!(other instanceof PairNeuronDouble)) {
return false;
}
return Double.doubleToRawLongBits(value) ==
Double.doubleToRawLongBits(((PairNeuronDouble) other).value);
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return Double.valueOf(value).hashCode();
}
} }
} }