Java Hash Code Calculate hashCode(byte[] array)

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

Description

bob jenkin's hash function

License

Open Source License

Declaration

public static final int hashCode(byte[] array) 

Method Source Code

//package com.java2s;
/*/*w w w  .  ja  v  a 2  s  .c  om*/
 * Created by Joseph Bridgewater
 * Created on Feb 24, 2006
 * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program 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 General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 * AELITIS, SAS au capital de 46,603.30 euros
 * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
 *
 */

public class Main {
    /**
     * bob jenkin's hash function 
     */
    public static final int hashCode(byte[] array) {
        int hash = 0;
        for (int i = 0; i < array.length; i++) {
            hash += array[i];
            hash += (hash << 10);
            hash ^= (hash >> 6);
        }
        hash += (hash << 3);
        hash ^= (hash >> 11);
        hash += (hash << 15);
        return hash;
    }
}

Related

  1. hashCode(boolean bool)
  2. hashCode(boolean bool)
  3. hashCode(boolean value)
  4. hashCode(byte a[])
  5. hashCode(byte a[], int offset, int length)
  6. hashCode(byte[] array, int size)
  7. hashCode(byte[] bytes, int offset, int length)
  8. hashCode(byte[] bytes, int size)
  9. hashCode(byte[] data, int offset, int len, int seed)