Java Hash Code Calculate hashCodeForDoubleArray(double[] a)

Here you can find the source of hashCodeForDoubleArray(double[] a)

Description

Returns a hash code for a double[] instance.

License

Open Source License

Parameter

Parameter Description
a the array (<code>null</code> permitted).

Return

The hash code.

Declaration

public static int hashCodeForDoubleArray(double[] a) 

Method Source Code

//package com.java2s;
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version./*  www . ja  va  2  s  . c  om*/
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
 * in the United States and other countries.]
 *
 * ------------------
 * HashUtilities.java
 * ------------------
 * (C) Copyright 2006-2008, by Object Refinery Limited;
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   -;
 *
 * Changes
 * -------
 * 03-Oct-2006 : Version 1 (DG);
 * 06-Mar-2007 : Fix for hashCodeForDoubleArray() method (DG);
 * 13-Nov-2007 : Added new utility methods (DG);
 * 22-Nov-2007 : Added hashCode() method for 'int' (DG);
 *
 */

public class Main {
    /**
     * Returns a hash code for a <code>double[]</code> instance.  If the array
     * is <code>null</code>, this method returns zero.
     *
     * @param a  the array (<code>null</code> permitted).
     *
     * @return The hash code.
     */
    public static int hashCodeForDoubleArray(double[] a) {
        if (a == null) {
            return 0;
        }
        int result = 193;
        long temp;
        for (int i = 0; i < a.length; i++) {
            temp = Double.doubleToLongBits(a[i]);
            result = 29 * result + (int) (temp ^ (temp >>> 32));
        }
        return result;
    }
}

Related

  1. hashCode(Object... toHash)
  2. hashCode(Object[] array)
  3. hashCode(Object[] thisFields)
  4. hashcode_old(final int[] array)
  5. hashCodeEps(double value)
  6. hashCodeLowerCase(Object... toHash)
  7. hashCodeNullSafe(final Object o)
  8. hashCodeOf(Object o)
  9. hashCodeOrDefault(Object obj)