jbil.util
Class BooleanArrayUtilities

java.lang.Object
  extended by jbil.util.BooleanArrayUtilities

public class BooleanArrayUtilities
extends java.lang.Object

Assorted boolean utility functions.

Author:
Paulo G. S. da Fonseca

Constructor Summary
BooleanArrayUtilities()
           
 
Method Summary
static boolean[] asIndicatorVector(int size, int[] trueElements)
          Creates an indicator array (boolean mask) from its size and the indexes of the true elements.
static int[] falseIndexes(boolean[] b)
          Returns an int array containing the indexes of the false entries of a boolean array.
static int falseIndexesCount(boolean[] b)
          Counts the false entries of a boolean array.
static void invert(boolean[] b)
          Inverts a boolean array.
static int[] trueIndexes(boolean[] b)
          Returns an int array containing the indexes of the true entries of a boolean array.
static int trueIndexesCount(boolean[] b)
          Counts the true entries of a boolean array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BooleanArrayUtilities

public BooleanArrayUtilities()
Method Detail

trueIndexesCount

public static int trueIndexesCount(boolean[] b)
Counts the true entries of a boolean array.


trueIndexes

public static int[] trueIndexes(boolean[] b)
Returns an int array containing the indexes of the true entries of a boolean array. For example, trueIndexes({true,false, false, true}) gives {0,3}.


falseIndexesCount

public static int falseIndexesCount(boolean[] b)
Counts the false entries of a boolean array.


falseIndexes

public static int[] falseIndexes(boolean[] b)
Returns an int array containing the indexes of the false entries of a boolean array. For example, trueIndexes({true,false, false, true}) gives {1,2}.


asIndicatorVector

public static boolean[] asIndicatorVector(int size,
                                          int[] trueElements)
Creates an indicator array (boolean mask) from its size and the indexes of the true elements. For example, asIndicatorVector(5, {2,3}) gives {false, false, true, true, false}.

Parameters:
size - The size of the indicator vector.
trueElements - The indexes of the true elements.

invert

public static void invert(boolean[] b)
Inverts a boolean array.

Parameters:
b - The array to be inverted.