Java Murmur Hash murmur2(int value, int salt)

Here you can find the source of murmur2(int value, int salt)

Description

The Murmur2 hash function.

License

Open Source License

Parameter

Parameter Description
value the value to hash
salt the value of the salt

Return

the result of the hash

Declaration

public static int murmur2(int value, int salt) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w ww .  ja  v a 2  s .  c o  m
     * The Murmur2 hash function.
     * @param value the value to hash
     * @param salt the value of the salt
     * @return the result of the hash
     */
    public static int murmur2(int value, int salt) {
        final int M = 0x5bd1e995;
        final int R = 24;

        int hash = salt;

        value *= M;
        value ^= value >>> R;
        value *= M;

        hash *= M;
        hash ^= value;

        hash ^= hash >>> 13;
        hash *= M;
        hash ^= hash >>> 15;

        return hash;
    }
}

Related

  1. murmur(String str, int seed)
  2. murmur2(final byte[] data)
  3. murmur3fmix(int value)
  4. murmurHash(byte[] data, int offset, int length)
  5. murmurHash(int code)
  6. murmurhash2_64(final byte[] data, int length, int seed)