public class DenseBitVector extends Object implements BitVector
Integer.MAX_VALUE
 1) * 64 (i.e. 137438953344, in which case it
uses around 16GigaByte of memory).Constructor and Description 

DenseBitVector(DenseBitVector clone)
Creates a new instance as copy of the passed argument.

DenseBitVector(long length)
Creates a new vector of the specified length, with no bits set.

DenseBitVector(long[] bits,
long length)
Creates a new instance taking over the initialization of the bits from
the passed array.

DenseBitVector(String hexString)
Initializes the created bit vector from the hex representation in the
passed string.

Modifier and Type  Method and Description 

DenseBitVector 
and(DenseBitVector bv)
Creates and returns a new bit vector whose bits are set at positions
where both, this and the argument vector have their bits set.

long 
cardinality()
Number of bits set in this bit vector.

(package private) long 
cardinalityOfIntersection(DenseBitVector bitVector)
Computes the cardinality of the intersection with the given bitVector.

(package private) long 
cardinalityOfRelativeComplement(DenseBitVector bitVector)
Computes the cardinality of the complement relative to the given bitVector.

void 
clear(long bitIdx)
Sets the bit at the specified index to one.

void 
clear(long startIdx,
long endIdx)
Clears all bits in the specified range.

DenseBitVector 
concatenate(DenseBitVector bv)
Creates and returns a new bit vector that contains copies of both (this
and the argument vector).

String 
dumpBits()
Returns a multiline dump of the internal storage.

boolean 
equals(Object obj) 
boolean 
get(long bitIdx)
Returns true if the bit at the specified index is set.

long[] 
getAllBits()
Returns a copy of the internal storage of all bits.

int 
hashCode() 
boolean 
intersects(DenseBitVector bv)
Returns true, if this and the argument vector have at least one bit set
at the same position.

DenseBitVector 
invert()
Creates and returns a new bit vector whose bits are inverted compared to
this vector.

boolean 
isEmpty()
Returns true if no bits are set in this bit vector.

long 
length()
Returns the number of bits stored in this vector.

long 
nextClearBit(long startIdx)
Finds the next bit not set (that is '0') on or after the specified index.

long 
nextSetBit(long startIdx)
Finds the next bit set to one on or after the specified index.

DenseBitVector 
or(DenseBitVector bv)
Creates and returns a new bit vector whose bits are set at positions
where at least one of the vectors (this or the argument vector) have a
bit set.

void 
set(long bitIdx)
Sets the bit at the specified index to zero.

void 
set(long bitIdx,
boolean value)
Sets the bit at the specified index to the new value.

void 
set(long startIdx,
long endIdx)
Sets all bits in the specified range.

void 
set(long startIdx,
long endIdx,
boolean value)
Sets all bits in the specified range to the new value.

DenseBitVector 
subSequence(long startIdx,
long endIdx)
Creates and returns a new bit vector that contains a subsequence of this
vector, beginning with the bit at index
startIdx and with
its last bit being this' bit at position endIdx  1 . 
String 
toBinaryString()
Returns the binary string representation of the bits in this vector.

String 
toHexString()
Returns the hex representation of the bits in this vector.

String 
toString()
Returns a string containing (comma separated) indices of the bits set in
this vector.

DenseBitVector 
xor(DenseBitVector bv)
Creates and returns a new bit vector whose bits are set at positions
where (exactly) one of the vectors (this or the argument vector) have a
bit set.

public DenseBitVector(long length)
length
 the length of the new bit vector.public DenseBitVector(long[] bits, long length)
getAllBits()
method.bits
 the array containing the initial values of the vectorlength
 the number of bits to use from the array. If the array is
too long (i.e. contains more than length bits) the additional
bits are ignored. If the array is too short, an exception is
thrown.IllegalArgumentException
 if length is negative or MAX_VALUE, or
if the length of the argument array is less than (length  1)
>> 6) + 1public DenseBitVector(String hexString)
'0'  '9'
,
'A'  'F'
and 'a'  'f'
are allowed. The
character at string position (length  1)
represents the
bits with index 0 to 3 in the vector. The character at position 0
represents the bits with the highest indices. The length of the vector
created is the length of the string times 4 (as each character represents
four bits).hexString
 containing the hex value to initialize the vector withIllegalArgumentException
 if hexString
contains
characters other then the hex characters (i.e.
0  9, A  F, and 'a'  'f'
)public DenseBitVector(DenseBitVector clone)
clone
 the vector to copy into the new instancepublic long length()
public void set(long bitIdx, boolean value)
public void set(long bitIdx)
public void set(long startIdx, long endIdx, boolean value)
startIdx
 the index of the first bit to set to the new valueendIdx
 the index of the last bit to set to the new valuevalue
 if set to true the bits are set to one, otherwise to zeropublic void set(long startIdx, long endIdx)
startIdx
 the index of the first bit to set to oneendIdx
 the index of the last bit to set to onepublic void clear(long bitIdx)
public void clear(long startIdx, long endIdx)
startIdx
 the index of the first bit to set to zeroendIdx
 the index of the last bit to set to zeropublic long cardinality()
cardinality
in interface BitVector
public boolean isEmpty()
public boolean intersects(DenseBitVector bv)
bv
 the vector to testpublic boolean get(long bitIdx)
public long nextSetBit(long startIdx)
nextSetBit
in interface BitVector
startIdx
 the first index to look for '1's. (It is allowed to pass
an index larger then the vector's length.)public long nextClearBit(long startIdx)
nextClearBit
in interface BitVector
startIdx
 the first index to look for '0's.public DenseBitVector subSequence(long startIdx, long endIdx)
startIdx
and with
its last bit being this' bit at position endIdx  1
. The
length of the result vector is endIdx  startIdx
. If
startIdx
equals endIdx
a vector of length
zero is returned.startIdx
 the startIdx of the subsequenceendIdx
 the first bit in this vector after startIdx that is not
included in the result sequence.endIdx  startIdx
containing the subsequence of this vector from
startIdx
(included) to endIdx
(not
included anymore).public DenseBitVector and(DenseBitVector bv)
bv
 the vector to AND this one withpublic DenseBitVector or(DenseBitVector bv)
bv
 the vector to OR this one withpublic DenseBitVector xor(DenseBitVector bv)
bv
 the vector to XOR this one withpublic DenseBitVector invert()
public DenseBitVector concatenate(DenseBitVector bv)
bv
 the vector to append at the end of thispublic String toString()
BitVectorValue.MAX_DISPLAY_BITS
. If the output is truncated, the string ends on "... }"public String toHexString()
'0'

'9'
and 'A'
 'F'
). The
character at string position (length  1)
holds the lowest
bits (bit 0 to 3), the character at position 0 represents the bits with
the largest index in the vector. If the length of the vector is larger
than BitVectorValue.MAX_DISPLAY_BITS
, the result is truncated (and ends with ...).toHexString
in interface BitVector
public String toBinaryString()
(length  1)
holds the bit with index 0, the character at position 0 represents the bits with the
largest index in the vector. If the length of the vector is larger than BitVectorValue.MAX_DISPLAY_BITS
,
the result is truncated (and ends with ...).toBinaryString
in interface BitVector
public long[] getAllBits()
public String dumpBits()
long cardinalityOfIntersection(DenseBitVector bitVector)
bitVector
 the other operand for the AND operatorBitVectorUtil.cardinalityOfIntersection(BitVectorValue, BitVectorValue)
long cardinalityOfRelativeComplement(DenseBitVector bitVector)
bitVector
 the other operandBitVectorUtil.cardinalityOfRelativeComplement(BitVectorValue, BitVectorValue)