Here you can find the source of maxdiffbits(int initoffset, int[] i, int pos, int length)
Parameter | Description |
---|---|
initoffset | introduce the difference to the first element |
i | a parameter |
pos | a parameter |
length | a parameter |
public static int maxdiffbits(int initoffset, int[] i, int pos, int length)
//package com.java2s; /**//from ww w . j a va 2s . c o m * This code is released under the * Apache License Version 2.0 http://www.apache.org/licenses/. * * (c) Daniel Lemire, http://lemire.me/en/ */ public class Main { /** * get the msb of differences among the consecutive input integers * * @param initoffset * introduce the difference to the first element * @param i * @param pos * @param length * @return */ public static int maxdiffbits(int initoffset, int[] i, int pos, int length) { int mask = 0; mask |= (i[pos] - initoffset); for (int k = pos + 1; k < pos + length; ++k) { mask |= i[k] - i[k - 1]; } return bits(mask); } public static int bits(int i) { return 32 - Integer.numberOfLeadingZeros(i); } }