Here you can find the source of bitHistogram(int[] data)
Parameter | Description |
---|---|
data | is the int sample |
public static int[] bitHistogram(int[] data)
//package com.java2s; public class Main { /**// w w w .j av a 2 s . c om * Make a histogram of bit number from a given sample of ints. * @param data is the int sample * @return an int[32] array in which each value is the number of times that bit was present */ public static int[] bitHistogram(int[] data) { int[] histogram = new int[32]; for (int i = 0; i < data.length; i++) { for (int b = 0; b < 32; b++) { histogram[b] += (1 & (data[i] >>> b)); } } return histogram; } }