public class ImmutableFixedLengthBitSet
extends java.lang.Object
BitSet
with fixed length. Objects
of this class are immutable.Modifier and Type | Field and Description |
---|---|
private boolean[] |
bitSet |
private int |
value |
Modifier | Constructor and Description |
---|---|
private |
ImmutableFixedLengthBitSet(boolean[] bitSet,
int value)
Constructs a new
ImmutableFixedLengthBitSet from an explicit
internal representation and value. |
|
ImmutableFixedLengthBitSet(int length)
Constructs a new
ImmutableFixedLengthBitSet for the given length. |
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<java.lang.Integer> |
getNonzeroPositions() |
int |
getNumOfZeroBits() |
int |
getValue() |
ImmutableFixedLengthBitSet |
inc()
Returns a new
ImmutableFixedLengthBitSet with a value incremented
by one compared to this ImmutableFixedLengthBitSet . |
private static int |
intPow(int a,
int b)
Power function for integers.
|
ImmutableFixedLengthBitSet |
setToValue(int value)
Sets this
ImmutableFixedLengthBitSet to the given value. |
java.lang.String |
toString() |
public ImmutableFixedLengthBitSet(int length)
ImmutableFixedLengthBitSet
for the given length.
All bits are set to zero (so the ImmutableFixedLengthBitSet
represents the number 0).length
- The length of the new ImmutableFixedLengthBitSet
.private ImmutableFixedLengthBitSet(boolean[] bitSet, int value)
ImmutableFixedLengthBitSet
from an explicit
internal representation and value. Note: It is not checked that the value
really faithfully represents the bitSet, so callers are responsible to
make sure that this property holds.bitSet
- The new bit set.value
- The value for bitSet.public int getValue()
ImmutableFixedLengthBitSet
.public ImmutableFixedLengthBitSet setToValue(int value)
ImmutableFixedLengthBitSet
to the given value.value
- Value to set the ImmutableFixedLengthBitSet
to.public ImmutableFixedLengthBitSet inc()
ImmutableFixedLengthBitSet
with a value incremented
by one compared to this ImmutableFixedLengthBitSet
.public int getNumOfZeroBits()
ImmutableFixedLengthBitSet
set
to zero.public java.util.ArrayList<java.lang.Integer> getNonzeroPositions()
ImmutableFixedLengthBitSet
.public java.lang.String toString()
toString
in class java.lang.Object
private static int intPow(int a, int b)
a
- The base.b
- The exponent.