Java Hash Calculate hash(long mover, long enemy)

Here you can find the source of hash(long mover, long enemy)

Description

Hash 2 longs into a single long, using a mixing function derived from Murmur.

License

Open Source License

Return

hash

Declaration

public static long hash(long mover, long enemy) 

Method Source Code

//package com.java2s;
/*/*w  w w  . java  2 s.  c  om*/
 * Copyright (c) 2014 Chris Welty.
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This file 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.
 *
 * For the license, see <http://www.gnu.org/licenses/gpl.html>.
 */

public class Main {
    /**
     * Hash 2 longs into a single long, using a mixing function derived from Murmur.
     *
     * @return hash
     */
    public static long hash(long mover, long enemy) {
        final long a = murmurMix(mover ^ murmurMix(enemy));
        return a ^ (a >>> 47);
    }

    /**
     * Index of units char in prefixes
     */
    private static long murmurMix(long h) {
        h *= 0xc6a4a7935bd1e995L;
        h ^= h >>> 47 | h << 17;
        h *= 0xc6a4a7935bd1e995L;
        return h;
    }
}

Related

  1. hash(int state1, int state2, int numStates1)
  2. hash(int val)
  3. hash(int value)
  4. hash(int x, int y)
  5. hash(long key)
  6. hash(Object a, Object b)
  7. hash(Object key, int limit)
  8. hash(Object o)
  9. hash(Object obj)