Here you can find the source of boolToBitSet(boolean[] bits, int offset, int length)
Parameter | Description |
---|---|
bits | Boolean array to convert. |
offset | Array index to start reading from. |
length | Number of bits to convert. |
public static BitSet boolToBitSet(boolean[] bits, int offset, int length)
//package com.java2s; //License from project: Open Source License import java.util.BitSet; public class Main { /**/*from w w w .j a v a2s. c o m*/ * Converts a boolean array into a BitSet * @param bits Boolean array to convert. * @param offset Array index to start reading from. * @param length Number of bits to convert. * @return */ public static BitSet boolToBitSet(boolean[] bits, int offset, int length) { BitSet bitset = new BitSet(length - offset); for (int i = offset; i < length; i++) bitset.set(i - offset, bits[i]); return bitset; } }