Modifier and Type  Field and Description 

static FinalBitSet 
EMPTY
An empty bit set of size 0.

Modifier and Type  Method and Description 

int 
cardinality()
Returns the number of bits set to
true in this BitSet . 
boolean 
equals(Object obj)
Compares this object against the specified object.

boolean 
get(int bitIndex)
Returns the value of the bit with the specified index.

int 
hashCode()
Returns the hash code value for this bit set.

boolean 
isEmpty()
Returns true if this
FinalBitSet contains no bits that are set to true . 
int 
length()
Returns the "logical size" of this
FinalBitSet : the index of the highest set bit in
the FinalBitSet plus one. 
int 
nextClearBit(int fromIndex)
Returns the index of the first bit that is set to
false that occurs on or after the
specified starting index. 
int 
nextSetBit(int fromIndex)
Returns the index of the first bit that is set to
true that occurs on or after the
specified starting index. 
int 
size()
Returns the number of bits of space actually in use by this
FinalBitSet to represent
bit values. 
long[] 
toLongArray()
Returns a new long array containing all the bits in this bit set.

String 
toString()
Returns a string representation of this bit set.

static FinalBitSet 
valueOf(BitSet originalBitSet)
Returns a new final bit set from a Java
BitSet instance. 
static FinalBitSet 
valueOf(long[] longs)
Returns a new bit set containing all the bits in the given long array.

public static final FinalBitSet EMPTY
public long[] toLongArray()
More precisely, if
long[] longs = s.toLongArray();
then longs.length == (s.length()+63)/64
and
s.get(n) == ((longs[n/64] & (1L<<(n%64))) != 0)
for all n < 64 * longs.length
.
public boolean get(int bitIndex)
true
if the bit
with the index bitIndex
is currently set in this FinalBitSet
; otherwise, the
result is false
. This method is designed for partial evaluation and is guaranteed to
fold if the receiver and the bitIndex parameter are constant.bitIndex
 the bit indexIndexOutOfBoundsException
 if the specified index is negativepublic int length()
FinalBitSet
: the index of the highest set bit in
the FinalBitSet
plus one. Returns zero if the FinalBitSet
contains no set
bits. This method is designed for partial evaluation and is guaranteed to fold if the
receiver is constant.FinalBitSet
public boolean isEmpty()
FinalBitSet
contains no bits that are set to true
. This
method is designed for partial evaluation and is guaranteed to fold if the receiver is
constant.FinalBitSet
is emptypublic boolean equals(Object obj)
true
if and only if
the argument is not null
and is a FinalBitSet
object that has exactly the
same set of bits set to true
as this bit set. That is, for every nonnegative
int
index k
,
((BitSet) obj).get(k) == this.get(k)must be true. The current sizes of the two bit sets are not compared.
equals
in class Object
obj
 the object to compare withtrue
if the objects are the same; false
otherwiseFinalBitSet.size()
public int hashCode()
FinalBitSet
.
The hash code is defined to be the result of the following calculation:
public int hashCode() {
long h = 1234;
long[] words = toLongArray();
for (int i = words.length; i >= 0;)
h ^= words[i] * (i + 1);
return (int) ((h >> 32) ^ h);
}
Note that the hash code changes if the set of bits is altered.public int size()
FinalBitSet
to represent
bit values. The maximum element in the set is the size  1st element. This method is designed
for partial evaluation and is guaranteed to fold if the receiver is constant.public int cardinality()
true
in this BitSet
.true
in this BitSet
public int nextSetBit(int fromIndex)
true
that occurs on or after the
specified starting index. If no such bit exists then 1
is returned.
To iterate over the true
bits in a FinalBitSet
, use the following loop:
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
// operate on index i here
if (i == Integer.MAX_VALUE) {
break; // or (i+1) would overflow
}
}
fromIndex
 the index to start checking from (inclusive)1
if there is no such bitIndexOutOfBoundsException
 if the specified index is negativepublic int nextClearBit(int fromIndex)
false
that occurs on or after the
specified starting index.fromIndex
 the index to start checking from (inclusive)IndexOutOfBoundsException
 if the specified index is negativepublic String toString()
BitSet
contains a bit in the set state, the decimal representation of that index is
included in the result. Such indices are listed in order from lowest to highest, separated by
", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical
notation for a set of integers.toString
in class Object
BitSet.toString()
public static FinalBitSet valueOf(long[] longs)
More precisely,
FinalBitSet.valueOf(longs).get(n) == ((longs[n/64] & (1L<<(n%64))) != 0)
for all n < 64 * longs.length
.
longs
 a long array containing a littleendian representation of a sequence of bits to
be used as the initial bits of the new bit setFinalBitSet
containing all the bits in the long arraypublic static FinalBitSet valueOf(BitSet originalBitSet)
BitSet
instance. The original bit set will be
copied.