Java Long to longToBucket(long key, int buckets)

Here you can find the source of longToBucket(long key, int buckets)

Description

long To Bucket

License

Open Source License

Declaration

public static final int longToBucket(long key, int buckets) 

Method Source Code

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

public class Main {
    public static final int longToBucket(long key, int buckets) {
        key = (~key) + (key << 18); // key = (key << 18) - key - 1;
        key ^= (key >>> 31);/*from   ww  w.j  a  va 2s  . c o  m*/
        key *= 21; // key = (key + (key << 2)) + (key << 4);
        key ^= (key >>> 11);
        key += (key << 6);
        key ^= (key >>> 22);
        int result = ((int) key) % buckets;
        return result < 0 ? result + buckets : result;
    }
}

Related

  1. longToBcd(long src, int len, int flag)
  2. longToBigEndian(long value, byte[] in, int offset)
  3. longToBinary(long num)
  4. longtobinarystring(long wert, int bits)
  5. longToBinaryStringUnsigned(long value)
  6. LongToBuf4(long val, byte[] buf, int offset)
  7. longToBuffer(long l, byte[] ioBuffer)
  8. longToCharArray(long seat, int length)
  9. longToCharBounds(long value)