Class BitVector
- All Implemented Interfaces:
Serializable, Cloneable
- See Also:
-
Field Summary
Fields inherited from class BitVectorBase
bits, BITS_PER_UNIT, DEBUG, LOG_BITS_PER_UNIT, LOW_MASK, MASK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidLogically ANDs this bit set with the specified set of bits.static BitVectorReturn a new bit string as the AND of two others.voidstatic BitVectorReturn a new bit string as the AND of two others.final voidclear(int bit) Clears a bit.booleanCompares this object against the specified object.final booleanget(int bit) Gets a bit.final booleanintersectionEmpty(BitVector other) Check if the intersection of the two sets is emptybooleanfinal intlength()Calculates and returns the set's size in bits.final voidnot()Logically NOT this bit stringstatic BitVectorReturn the NOT of a bit stringfinal voidLogically ORs this bit set with the specified set of bits.static BitVectorReturn a new FixedSizeBitVector as the OR of two othersfinal intorWithDelta(BitVector set) Logically ORs this bit set with the specified set of bits.final booleanCompares this object against the specified object.final voidset(int bit) Sets a bit.final voidsetAll()Sets all bits.final voidLogically XORs this bit set with the specified set of bits.static BitVectorReturn a new FixedSizeBitVector as the XOR of two othersMethods inherited from class BitVectorBase
clearAll, clone, contains, copyBits, hashCode, isZero, max, nextSetBit, populationCount, subscript, toString
-
Constructor Details
-
BitVector
public BitVector() -
BitVector
public BitVector(int nbits) Creates an empty string with the specified size.- Parameters:
nbits- the size of the string
-
BitVector
Creates a copy of a Bit String- Parameters:
s- the string to copy- Throws:
IllegalArgumentException- if s is null
-
-
Method Details
-
set
public final void set(int bit) Sets a bit.- Specified by:
setin classBitVectorBase<BitVector>- Parameters:
bit- the bit to be set
-
clear
public final void clear(int bit) Clears a bit.- Specified by:
clearin classBitVectorBase<BitVector>- Parameters:
bit- the bit to be cleared
-
get
public final boolean get(int bit) Gets a bit.- Specified by:
getin classBitVectorBase<BitVector>- Parameters:
bit- the bit to be gotten
-
not
-
and
Logically ANDs this bit set with the specified set of bits.- Specified by:
andin classBitVectorBase<BitVector>- Parameters:
set- the bit set to be ANDed with
-
and
-
or
Logically ORs this bit set with the specified set of bits.- Specified by:
orin classBitVectorBase<BitVector>- Parameters:
set- the bit set to be ORed with
-
orWithDelta
Logically ORs this bit set with the specified set of bits. This is performance-critical, and so, a little ugly in an attempt to help out the compiler.- Returns:
- the number of bits added to this.
- Throws:
IllegalArgumentException- if set is null
-
or
-
xor
-
xor
Logically XORs this bit set with the specified set of bits.- Specified by:
xorin classBitVectorBase<BitVector>- Parameters:
set- the bit set to be XORed with- Throws:
IllegalArgumentException- if set is null
-
intersectionEmpty
Check if the intersection of the two sets is empty- Specified by:
intersectionEmptyin classBitVectorBase<BitVector>- Parameters:
other- the set to check intersection with- Throws:
IllegalArgumentException- if other is null
-
length
public final int length()Calculates and returns the set's size in bits. The maximum element in the set is the size - 1st element.- Specified by:
lengthin classBitVectorBase<BitVector>
-
sameBits
Compares this object against the specified object.- Specified by:
sameBitsin classBitVectorBase<BitVector>- Parameters:
B- the object to compare with- Returns:
- true if the objects are the same; false otherwise.
-
isSubset
- Specified by:
isSubsetin classBitVectorBase<BitVector>- Returns:
- true iff this is a subset of other
-
andNot
- Specified by:
andNotin classBitVectorBase<BitVector>
-
equals
-
setAll
public final void setAll()Sets all bits. -
not
public final void not()Logically NOT this bit string -
andNot
-