Java BitSet boolToBitSet(boolean[] bits, int offset, int length)

Here you can find the source of boolToBitSet(boolean[] bits, int offset, int length)

Description

Converts a boolean array into a BitSet

License

Open Source License

Parameter

Parameter Description
bits Boolean array to convert.
offset Array index to start reading from.
length Number of bits to convert.

Declaration

public static BitSet boolToBitSet(boolean[] bits, int offset, int length) 

Method Source Code

//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;
    }
}

Related

  1. binaryStringToBitSet(String stringRepresentation)
  2. binaryToGray(BitSet binary)
  3. bitsetCopy(BitSet src, int srcOffset, BitSet dest, int destOffset, int length)
  4. bitSetTest(BitSet bitSet, int index)
  5. BitString2BitSet(String string)
  6. byte2BitSet(BitSet bmap, byte[] b, int bitOffset)
  7. byteArray2BitSet(byte[] bytes)
  8. bytes2bitset(byte[] bytes, byte nbyte, BitSet bits)
  9. bytesToBits(byte[] b, BitSet ba, int maxSize)