You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2008/11/22 21:25:27 UTC

svn commit: r719909 - /commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java

Author: psteitz
Date: Sat Nov 22 12:25:27 2008
New Revision: 719909

URL: http://svn.apache.org/viewvc?rev=719909&view=rev
Log:
Replace hashcode functions with JDK 1.5+ provided impls. Deprecate?

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java?rev=719909&r1=719908&r2=719909&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/MathUtils.java Sat Nov 22 12:25:27 2008
@@ -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 @@
      * @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);
     }
 
     /**