Java Array Max Value maxbits32(int[] i, int pos)

Here you can find the source of maxbits32(int[] i, int pos)

Description

get the msb of 32 elements of the input list

License

Open Source License

Parameter

Parameter Description
i a parameter
pos a parameter

Declaration

public static int maxbits32(int[] i, int pos) 

Method Source Code

//package com.java2s;
/**//from  w  ww  .  jav a2 s . c  om
 * 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 32 elements of the input list
     * 
     * @param i
     * @param pos
     * @return
     */
    public static int maxbits32(int[] i, int pos) {
        int mask = i[pos];
        mask |= i[pos + 1];
        mask |= i[pos + 2];
        mask |= i[pos + 3];
        mask |= i[pos + 4];
        mask |= i[pos + 5];
        mask |= i[pos + 6];
        mask |= i[pos + 7];
        mask |= i[pos + 8];
        mask |= i[pos + 9];
        mask |= i[pos + 10];
        mask |= i[pos + 11];
        mask |= i[pos + 12];
        mask |= i[pos + 13];
        mask |= i[pos + 14];
        mask |= i[pos + 15];
        mask |= i[pos + 16];
        mask |= i[pos + 17];
        mask |= i[pos + 18];
        mask |= i[pos + 19];
        mask |= i[pos + 20];
        mask |= i[pos + 21];
        mask |= i[pos + 22];
        mask |= i[pos + 23];
        mask |= i[pos + 24];
        mask |= i[pos + 25];
        mask |= i[pos + 26];
        mask |= i[pos + 27];
        mask |= i[pos + 28];
        mask |= i[pos + 29];
        mask |= i[pos + 30];
        mask |= i[pos + 31];
        return bits(mask);
    }

    public static int bits(int i) {
        return 32 - Integer.numberOfLeadingZeros(i);
    }
}

Related

  1. maxarr(double[] a)
  2. maxArray(double[] input)
  3. maxArray(int[] arr)
  4. maxBetween(int[] arr1, int[] arr2)
  5. maxbits(int[] i, int pos, int length)
  6. maxCommonLeadingWhitespaceForAll(String[] strings)
  7. maxcount(int[] vals, int max, int maxcount)
  8. maxDblArrayValue(int npts, double[] dbls)
  9. maxdex(float... values)