Java Murmur Hash murmurHash3(int x)

Here you can find the source of murmurHash3(int x)

Description

murmur Hash

License

Open Source License

Declaration

public static int murmurHash3(int x) 

Method Source Code

//package com.java2s;
/*/*from  w  w w  .  j  a v  a2 s  . c om*/
 * Copyright (c) 2017 VMware Inc. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static int murmurHash3(int x) {
        x ^= x >>> 16;
        x *= -2048144789;
        x ^= x >>> 13;
        x *= -1028477387;
        x ^= x >>> 16;
        return x;
    }

    private static long murmurHash3(long x) {
        x ^= x >>> 33;
        x *= -49064778989728563L;
        x ^= x >>> 33;
        x *= -4265267296055464877L;
        x ^= x >>> 33;
        return x;
    }

    public static long murmurHash3(long seed, long data) {
        long h1 = murmurHash3(data);
        h1 = h1 ^ seed;
        return murmurHash3(h1);
    }

    public static int murmurHash3(int seed, int data) {
        int h1 = murmurHash3(data);
        h1 = h1 ^ seed;
        return murmurHash3(h1);
    }
}

Related

  1. murmurHash(byte[] data, int offset, int length)
  2. murmurHash(int code)
  3. murmurhash2_64(final byte[] data, int length, int seed)
  4. murmurHash3(int k)
  5. murmurHash3(int x)
  6. MurmurHash3_fmix(int k)
  7. murmurhash3x8632(byte[] data, int offset, int len, int seed)
  8. murmurMix(long h)
  9. murmurRehash(final int hash)