Java BitSet to bitsetToDoubleArray(BitSet bs, int n)

Here you can find the source of bitsetToDoubleArray(BitSet bs, int n)

Description

Create an n-element array of doubles (0s and 1s) from a BitSet.

License

Open Source License

Parameter

Parameter Description
bs The bitset specifying 0s and 1s
n The size of the array.

Declaration

public static double[] bitsetToDoubleArray(BitSet bs, int n) 

Method Source Code

//package com.java2s;
//   it under the terms of the GNU General Public License as published by

import java.util.BitSet;

public class Main {
    /**//  w  ww  . ja  v  a 2s. co  m
     * Create an n-element array of doubles (0s and 1s) from a BitSet.
     *  @param bs The bitset specifying 0s and 1s
     *  @param n The size of the array.
     */
    public static double[] bitsetToDoubleArray(BitSet bs, int n) {
        int i;
        double res[] = new double[n];
        for (i = 0; i < n; i++)
            res[i] = bs.get(i) ? 1.0 : 0.0;
        return res;
    }
}

Related

  1. Bitset2BitString(BitSet bitset, int length)
  2. bitSet2byte(BitSet b, int bytes)
  3. bitset2bytes(BitSet bits, byte[] bytes)
  4. bitSet2extendedByte(BitSet b)
  5. bitSet2Int(BitSet bs)
  6. bitsetToIndices(BitSet bits)
  7. bitSetToInt(final BitSet bitSet)
  8. bitSetToLong(BitSet set)
  9. bitSetToMap(Map map, String key, BitSet bits, int length)