Top Description Constructors Methods
org.droidparts.dexmaker.dx.util

public final Class Bits

extends Object
Class Inheritance

Utilities for treating int[]s as bit sets.

Constructor Summary

AccessConstructor and Description
private
Bits()

This class is uninstantiable.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if any bit is set to true in the indicated range
anyInRange
(int[]
non-null; bit set to operate on
bits
,
int
>= 0; index of the first bit in the range (inclusive)
start
,
int
>= 0; index of the last bit in the range (exclusive)
end
)

Returns whether any bits are set to true in the specified range.

public static int

Returns:

>= 0; the bit count (aka population count) of the set
bitCount
(int[]
non-null; bit set to operate on
bits
)

Gets the number of bits set to true in the given bit set.

public static void
clear(int[]
non-null; bit set to operate on
bits
,
int
>= 0, < getMax(set); which bit
idx
)

Sets the given bit to false.

public static int

Returns:

>= -1; lowest-order bit set at or after idx, or -1 if there is no appropriate bit index to return
findFirst
(int[]
non-null; bit set to operate on
bits
,
int
>= 0; minimum index to return
idx
)

Finds the lowest-order bit set at or after the given index in the given bit set.

public static int

Returns:

>= -1; lowest-order bit set at or after idx, or -1 if there is no appropriate bit index to return
findFirst
(int
the value in question
value
,
int
0..31 the minimum bit index to return
idx
)

Finds the lowest-order bit set at or after the given index in the given int.

public static boolean

Returns:

the value of the indicated bit
get
(int[]
non-null; bit set to operate on
bits
,
int
>= 0, < getMax(set); which bit
idx
)

Gets the value of the bit at the given index.

public static int

Returns:

>= 0; the maximum index (exclusive) that may be set
getMax
(int[]
non-null; bit set in question
bits
)

Gets the maximum index (exclusive) for the given bit set.

public static boolean

Returns:

true iff all bits are false
isEmpty
(int[]
non-null; bit set to operate on
bits
)

Returns whether or not the given bit set is empty, that is, whether no bit is set to true.

public static int[]

Returns:

non-null; an appropriately-constructed instance
makeBitSet
(int
>= 0; the maximum bit index (exclusive)
max
)

Constructs a bit set to contain bits up to the given index (exclusive).

public static void
or(int[]
non-null; int array to be ored with other argument. This argument is modified.
a
,
int[]
non-null; int array to be ored into a. This argument is not modified.
b
)

Ors bit array b into bit array a.

public static void
set(int[]
non-null; bit set to operate on
bits
,
int
>= 0, < getMax(set); which bit
idx
,
boolean
the new value for the bit
value
)

Sets the given bit to the given value.

public static void
set(int[]
non-null; bit set to operate on
bits
,
int
>= 0, < getMax(set); which bit
idx
)

Sets the given bit to true.

public static String
toHuman(int[] bits)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Bitsback to summary
private Bits()

This class is uninstantiable.

Method Detail

anyInRangeback to summary
public static boolean anyInRange(int[] bits, int start, int end)

Returns whether any bits are set to true in the specified range.

Parameters
bits:int[]

non-null; bit set to operate on

start:int

>= 0; index of the first bit in the range (inclusive)

end:int

>= 0; index of the last bit in the range (exclusive)

Returns:boolean

true if any bit is set to true in the indicated range

bitCountback to summary
public static int bitCount(int[] bits)

Gets the number of bits set to true in the given bit set.

Parameters
bits:int[]

non-null; bit set to operate on

Returns:int

>= 0; the bit count (aka population count) of the set

clearback to summary
public static void clear(int[] bits, int idx)

Sets the given bit to false.

Parameters
bits:int[]

non-null; bit set to operate on

idx:int

>= 0, < getMax(set); which bit

findFirstback to summary
public static int findFirst(int[] bits, int idx)

Finds the lowest-order bit set at or after the given index in the given bit set.

Parameters
bits:int[]

non-null; bit set to operate on

idx:int

>= 0; minimum index to return

Returns:int

>= -1; lowest-order bit set at or after idx, or -1 if there is no appropriate bit index to return

findFirstback to summary
public static int findFirst(int value, int idx)

Finds the lowest-order bit set at or after the given index in the given int.

Parameters
value:int

the value in question

idx:int

0..31 the minimum bit index to return

Returns:int

>= -1; lowest-order bit set at or after idx, or -1 if there is no appropriate bit index to return

getback to summary
public static boolean get(int[] bits, int idx)

Gets the value of the bit at the given index.

Parameters
bits:int[]

non-null; bit set to operate on

idx:int

>= 0, < getMax(set); which bit

Returns:boolean

the value of the indicated bit

getMaxback to summary
public static int getMax(int[] bits)

Gets the maximum index (exclusive) for the given bit set.

Parameters
bits:int[]

non-null; bit set in question

Returns:int

>= 0; the maximum index (exclusive) that may be set

isEmptyback to summary
public static boolean isEmpty(int[] bits)

Returns whether or not the given bit set is empty, that is, whether no bit is set to true.

Parameters
bits:int[]

non-null; bit set to operate on

Returns:boolean

true iff all bits are false

makeBitSetback to summary
public static int[] makeBitSet(int max)

Constructs a bit set to contain bits up to the given index (exclusive).

Parameters
max:int

>= 0; the maximum bit index (exclusive)

Returns:int[]

non-null; an appropriately-constructed instance

orback to summary
public static void or(int[] a, int[] b)

Ors bit array b into bit array a. a.length must be greater than or equal to b.length.

Parameters
a:int[]

non-null; int array to be ored with other argument. This argument is modified.

b:int[]

non-null; int array to be ored into a. This argument is not modified.

setback to summary
public static void set(int[] bits, int idx, boolean value)

Sets the given bit to the given value.

Parameters
bits:int[]

non-null; bit set to operate on

idx:int

>= 0, < getMax(set); which bit

value:boolean

the new value for the bit

setback to summary
public static void set(int[] bits, int idx)

Sets the given bit to true.

Parameters
bits:int[]

non-null; bit set to operate on

idx:int

>= 0, < getMax(set); which bit

toHumanback to summary
public static String toHuman(int[] bits)