Java BitSet toArray(BitSet bitset, int size)

Here you can find the source of toArray(BitSet bitset, int size)

Description

Convert a BitSet into an array of boolean.

License

Apache License

Parameter

Parameter Description
bitset set of bits to convert
size number of bits to convert. length() it not useful here, and size() may not give the number you want.

Return

result of conversion

Declaration

public static boolean[] toArray(BitSet bitset, int size) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.BitSet;

public class Main {
    /**/*from   w  ww . j  av  a  2  s .c o  m*/
     * Convert a BitSet into an array of boolean.
     * 
     * @param bitset set of bits to convert
     * @param size number of bits to convert.  length() it not useful here, and size() may
     *     not give the number you want.
     * @return result of conversion
     */
    public static boolean[] toArray(BitSet bitset, int size) {
        boolean[] b = new boolean[size];
        for (int i = 0; i < size; i++)
            b[i] = bitset.get(i);
        return b;
    }
}

Related

  1. shiftRight(BitSet bitset, int n)
  2. storeCharSet(BitSet stored, String... validCharStrings)
  3. strArrToBitSet(String stringArray)
  4. stringToBitSet(String sbits)
  5. stripToCommonChars(char[] ac, BitSet commonChars)
  6. toBitSet(byte[] array)
  7. toBitSet(byte[] bytes)
  8. toBitSet(final byte[] bytes)
  9. toBitSet(String data)