Here you can find the source of maxbits(int[] i, int pos, int length)
Parameter | Description |
---|---|
i | input list |
pos | start position |
length | end position |
public static int maxbits(int[] i, int pos, int length)
//package com.java2s; /**/*from w w w .j a va2s .com*/ * 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 all the elements between the range of pos and length of * the input list * * @param i * input list * @param pos * start position * @param length * end position * @return msb of the list */ public static int maxbits(int[] i, int pos, int length) { int mask = 0; for (int k = pos; k < pos + length; ++k) mask |= i[k]; return bits(mask); } public static int bits(int i) { return 32 - Integer.numberOfLeadingZeros(i); } }