Java Hash Calculate hashBerkeleyDB64(byte[] str)

Here you can find the source of hashBerkeleyDB64(byte[] str)

Description

A hash function used in Berkeley DB

License

Open Source License

Parameter

Parameter Description
str Value to be hashed

Return

the 64bit hash code

Declaration

public static long hashBerkeleyDB64(byte[] str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w  w  w. j ava  2  s .c o m
     * A hash function used in Berkeley DB
     *  
     * @param str Value to be hashed
     * @return the 64bit hash code
     */
    public static long hashBerkeleyDB64(String str) {
        return hashBerkeleyDB64(str.getBytes());
    }

    /**
     * A hash function used in Berkeley DB
     *  
     * @param str Value to be hashed
     * @return the 64bit hash code
     */
    public static long hashBerkeleyDB64(byte[] str) {
        long hash = 0;

        for (int i = 0; i < str.length; i++) {
            hash = str[i] + (hash << 6) + (hash << 16) - hash;
        }

        return hash;
    }
}

Related

  1. hashAll(Object[] array)
  2. hasHangulJongSung(char ch)
  3. hashArray(int h, Object[] a)
  4. hashArray(Object[] array)
  5. hashArray(Object[] objs)
  6. hashByteArray(byte[] array, int startInclusive, int endExclusive)
  7. hashBytes(int seed, byte[] data, int offset, int len)
  8. hashCapacityForSize(final int size)
  9. hashCharArray(int seed, char... charArray)