Replace hashcode functions with JDK 1.5+ provided impls. Deprecate?

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@719909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2008-11-22 20:25:27 +00:00
parent 444d2311ea
commit 05c6b8ad5a
1 changed files with 4 additions and 11 deletions

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.util;
import java.math.BigDecimal;
import java.util.Arrays;
/**
* Some useful additions to the built-in functions in {@link Math}.
@ -465,26 +466,18 @@ public final class MathUtils {
* @return the hash code
*/
public static int hash(double value) {
long bits = Double.doubleToLongBits(value);
return (int)(bits ^ (bits >>> 32));
return new Double(value).hashCode();
}
/**
* Returns an integer hash code representing the given double array value.
* Returns an integer hash code representing the given double array.
*
* @param value the value to be hashed (may be null)
* @return the hash code
* @since 1.2
*/
public static int hash(double[] value) {
if (value == null) {
return 0;
}
int result = value.length;
for (int i = 0; i < value.length; ++i) {
result = result * 31 + hash(value[i]);
}
return result;
return Arrays.hashCode(value);
}
/**