Java Array Hash Code byteArrayHashCode(final byte[] array)

Here you can find the source of byteArrayHashCode(final byte[] array)

Description

Obtain the hashcode of a byte array.

License

LGPL

Parameter

Parameter Description
array The array to obtain the hash code off.

Return

The hash code of the array.

Declaration

public static final int byteArrayHashCode(final byte[] array) 

Method Source Code


//package com.java2s;
/*/*from   w  w w .  jav  a2s  .  com*/
 * Copyright (c) 2006 Thomas Weise
 * Software Foundation Classes
 * http://sourceforge.net/projects/java-sfc
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-11-22
 * Creator          : Thomas Weise
 * Original Filename: org.sfc.utils.HashUtils.java
 * Last modification: 2006-11-22
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to theFree Software
 *                    Foundation, Inc. 51 Franklin Street, Fifth Floor,
 *                    Boston, MA 02110-1301, USA or download the license
 *                    under http://www.gnu.org/licenses/lgpl.html or
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" 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.
 */

import java.util.Arrays;

public class Main {
    /**
     * Obtain the hashcode of a byte array.
     * 
     * @param array
     *          The array to obtain the hash code off.
     * @return The hash code of the array.
     */
    public static final int byteArrayHashCode(final byte[] array) {
        //    int i, s;
        //
        //    if (array == null)
        //      return -3413;
        //    i = array.length;
        //    if (i <= 0)
        //      return -928547;
        //
        //    s = byteHashCode(array[0]);
        //    for (--i; i > 0; i--) {
        //      s = combineHashCodes(s, array[i]);
        //    }
        //
        //    return s;
        return Arrays.hashCode(array);
    }
}

Related

  1. arrayHashCode(Object array[])
  2. arrayHashCode(Object[] arr)
  3. arrayHashCode(Object[] arr)
  4. arrayHashCode(Object[] objects)
  5. calculateHash(byte[] data)
  6. deepHash(Object[] t)
  7. deepHashCode(double[][] matrix)
  8. hashCode(byte[] bytes)