Java Boolean Convert to booleanArrayToIntIndexes(boolean[] arrb)

Here you can find the source of booleanArrayToIntIndexes(boolean[] arrb)

Description

Set elements of arrb true if their indexes appear in arrb.

License

Open Source License

Declaration

public static int[] booleanArrayToIntIndexes(boolean[] arrb) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w ww  . j  a va  2 s  . c o m*/
     * Set elements of arrb true if their indexes appear in arrb.
     */
    public static int[] booleanArrayToIntIndexes(boolean[] arrb) {

        int count = 0;

        for (int i = 0; i < arrb.length; i++) {
            if (arrb[i]) {
                count++;
            }
        }

        int[] intarr = new int[count];

        count = 0;

        for (int i = 0; i < arrb.length; i++) {
            if (arrb[i]) {
                intarr[count++] = i;
            }
        }

        return intarr;
    }
}

Related

  1. boolean2double(boolean b)
  2. boolean2long(boolean b)
  3. booleanArrayToBitString(final boolean[] booleanArray)
  4. booleanArrayToBytes(boolean[] input)
  5. booleanArrayToInt(boolean[] in)
  6. booleanArrayToString(boolean[] array)
  7. booleanArrayToString(boolean[] b, String delim)
  8. booleanArrayToString(boolean[] ba)
  9. booleanToBasicType(boolean b, Class clazz)