commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1413096 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java
Date Fri, 23 Nov 2012 22:34:06 GMT
Author: erans
Date: Fri Nov 23 22:34:05 2012
New Revision: 1413096

URL: http://svn.apache.org/viewvc?rev=1413096&view=rev
Log:
Using methods from JDK.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java?rev=1413096&r1=1413095&r2=1413096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/clustering/EuclideanDoublePoint.java
Fri Nov 23 22:34:05 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.cl
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.Arrays;
 
 import org.apache.commons.math3.util.MathArrays;
 
@@ -70,16 +71,7 @@ public class EuclideanDoublePoint implem
         if (!(other instanceof EuclideanDoublePoint)) {
             return false;
         }
-        final double[] otherPoint = ((EuclideanDoublePoint) other).getPoint();
-        if (point.length != otherPoint.length) {
-            return false;
-        }
-        for (int i = 0; i < point.length; i++) {
-            if (point[i] != otherPoint[i]) {
-                return false;
-            }
-        }
-        return true;
+        return Arrays.equals(point, ((EuclideanDoublePoint) other).point);
     }
 
     /**
@@ -94,26 +86,13 @@ public class EuclideanDoublePoint implem
     /** {@inheritDoc} */
     @Override
     public int hashCode() {
-        int hashCode = 0;
-        for (final Double i : point) {
-            hashCode += i.hashCode() * 13 + 7;
-        }
-        return hashCode;
+        return Arrays.hashCode(point);
     }
 
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        final StringBuilder buff = new StringBuilder("(");
-        final double[] coordinates = getPoint();
-        for (int i = 0; i < coordinates.length; i++) {
-            buff.append(coordinates[i]);
-            if (i < coordinates.length - 1) {
-                buff.append(',');
-            }
-        }
-        buff.append(')');
-        return buff.toString();
+        return Arrays.toString(point);
     }
 
 }



Mime
View raw message