Package com.ibm.wala.util.intset
Class BitVector
- java.lang.Object
-
- com.ibm.wala.util.intset.BitVectorBase<BitVector>
-
- com.ibm.wala.util.intset.BitVector
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class BitVector extends BitVectorBase<BitVector>
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.ibm.wala.util.intset.BitVectorBase
bits, BITS_PER_UNIT, DEBUG, LOG_BITS_PER_UNIT, LOW_MASK, MASK
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
and(BitVector set)
Logically ANDs this bit set with the specified set of bits.static BitVector
and(BitVector b1, BitVector b2)
Return a new bit string as the AND of two others.void
andNot(BitVector vector)
static BitVector
andNot(BitVector b1, BitVector b2)
Return a new bit string as the AND of two others.void
clear(int bit)
Clears a bit.boolean
equals(java.lang.Object obj)
Compares this object against the specified object.boolean
get(int bit)
Gets a bit.boolean
intersectionEmpty(BitVector other)
Check if the intersection of the two sets is emptyboolean
isSubset(BitVector other)
int
length()
Calculates and returns the set's size in bits.void
not()
Logically NOT this bit stringstatic BitVector
not(BitVector s)
Return the NOT of a bit stringvoid
or(BitVector set)
Logically ORs this bit set with the specified set of bits.static BitVector
or(BitVector b1, BitVector b2)
Return a new FixedSizeBitVector as the OR of two othersint
orWithDelta(BitVector set)
Logically ORs this bit set with the specified set of bits.boolean
sameBits(BitVector B)
Compares this object against the specified object.void
set(int bit)
Sets a bit.void
setAll()
Sets all bits.void
xor(BitVector set)
Logically XORs this bit set with the specified set of bits.static BitVector
xor(BitVector b1, BitVector b2)
Return a new FixedSizeBitVector as the XOR of two others-
Methods inherited from class com.ibm.wala.util.intset.BitVectorBase
clearAll, clone, contains, copyBits, hashCode, isZero, max, nextSetBit, populationCount, subscript, toString
-
-
-
-
Constructor Detail
-
BitVector
public BitVector()
-
BitVector
public BitVector(int nbits)
Creates an empty string with the specified size.- Parameters:
nbits
- the size of the string
-
BitVector
public BitVector(BitVector s)
Creates a copy of a Bit String- Parameters:
s
- the string to copy- Throws:
java.lang.IllegalArgumentException
- if s is null
-
-
Method Detail
-
set
public final void set(int bit)
Sets a bit.- Specified by:
set
in classBitVectorBase<BitVector>
- Parameters:
bit
- the bit to be set
-
clear
public final void clear(int bit)
Clears a bit.- Specified by:
clear
in classBitVectorBase<BitVector>
- Parameters:
bit
- the bit to be cleared
-
get
public final boolean get(int bit)
Gets a bit.- Specified by:
get
in classBitVectorBase<BitVector>
- Parameters:
bit
- the bit to be gotten
-
and
public final void and(BitVector set)
Logically ANDs this bit set with the specified set of bits.- Specified by:
and
in classBitVectorBase<BitVector>
- Parameters:
set
- the bit set to be ANDed with
-
and
public static BitVector and(BitVector b1, BitVector b2)
Return a new bit string as the AND of two others.
-
or
public final void or(BitVector set)
Logically ORs this bit set with the specified set of bits.- Specified by:
or
in classBitVectorBase<BitVector>
- Parameters:
set
- the bit set to be ORed with
-
orWithDelta
public final int orWithDelta(BitVector set)
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.- Parameters:
set
-- Returns:
- the number of bits added to this.
- Throws:
java.lang.IllegalArgumentException
- if set is null
-
or
public static BitVector or(BitVector b1, BitVector b2)
Return a new FixedSizeBitVector as the OR of two others
-
xor
public static BitVector xor(BitVector b1, BitVector b2)
Return a new FixedSizeBitVector as the XOR of two others
-
xor
public final void xor(BitVector set)
Logically XORs this bit set with the specified set of bits.- Specified by:
xor
in classBitVectorBase<BitVector>
- Parameters:
set
- the bit set to be XORed with- Throws:
java.lang.IllegalArgumentException
- if set is null
-
intersectionEmpty
public final boolean intersectionEmpty(BitVector other)
Check if the intersection of the two sets is empty- Specified by:
intersectionEmpty
in classBitVectorBase<BitVector>
- Parameters:
other
- the set to check intersection with- Throws:
java.lang.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:
length
in classBitVectorBase<BitVector>
-
sameBits
public final boolean sameBits(BitVector B)
Compares this object against the specified object.- Specified by:
sameBits
in classBitVectorBase<BitVector>
- Parameters:
B
- the object to compare with- Returns:
- true if the objects are the same; false otherwise.
-
isSubset
public boolean isSubset(BitVector other)
- Specified by:
isSubset
in classBitVectorBase<BitVector>
- Returns:
- true iff this is a subset of other
-
andNot
public void andNot(BitVector vector)
- Specified by:
andNot
in classBitVectorBase<BitVector>
-
equals
public boolean equals(java.lang.Object obj)
Compares this object against the specified object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare with- Returns:
- true if the objects are the same; false otherwise.
-
setAll
public final void setAll()
Sets all bits.
-
not
public final void not()
Logically NOT this bit string
-
-