Here you can find the source of murmurHash3(int x)
Parameter | Description |
---|---|
x | an integer. |
public final static int murmurHash3(int x)
//package com.java2s; /* /*from ww w . j a v a 2 s . c o m*/ * Copyright (C) 2002-2015 Sebastiano Vigna * * 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 { /** Avalanches the bits of an integer by applying the finalisation step of MurmurHash3. * * <p>This method implements the finalisation step of Austin Appleby's <a href="http://code.google.com/p/smhasher/">MurmurHash3</a>. * Its purpose is to avalanche the bits of the argument to within 0.25% bias. * * @param x an integer. * @return a hash value with good avalanching properties. */ public final static int murmurHash3(int x) { x ^= x >>> 16; x *= 0x85ebca6b; x ^= x >>> 13; x *= 0xc2b2ae35; x ^= x >>> 16; return x; } /** Avalanches the bits of a long integer by applying the finalisation step of MurmurHash3. * * <p>This method implements the finalisation step of Austin Appleby's <a href="http://code.google.com/p/smhasher/">MurmurHash3</a>. * Its purpose is to avalanche the bits of the argument to within 0.25% bias. * * @param x a long integer. * @return a hash value with good avalanching properties. */ public final static long murmurHash3(long x) { x ^= x >>> 33; x *= 0xff51afd7ed558ccdL; x ^= x >>> 33; x *= 0xc4ceb9fe1a85ec53L; x ^= x >>> 33; return x; } }