Package com.ibm.wala.util.intset
Class FixedSizeBitVector
- java.lang.Object
-
- com.ibm.wala.util.intset.FixedSizeBitVector
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public final class FixedSizeBitVector extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description FixedSizeBitVector(int nbits)
Creates an empty string with the specified size.FixedSizeBitVector(FixedSizeBitVector s)
Creates a copy of a Bit String
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
and(FixedSizeBitVector set)
Logically ANDs this bit set with the specified set of bits.static FixedSizeBitVector
and(FixedSizeBitVector b1, FixedSizeBitVector b2)
Return a new bit string as the AND of two others.void
clear(int bit)
Clears a bit.void
clearAll()
Clears all bits.java.lang.Object
clone()
Clones the FixedSizeBitVector.void
copyBits(FixedSizeBitVector set)
Copies the values of the bits in the specified set into this set.boolean
equals(java.lang.Object obj)
Compares this object against the specified object.boolean
get(int bit)
Gets a bit.int
hashCode()
Gets the hashcode.boolean
intersectionEmpty(FixedSizeBitVector other)
Check if the intersection of the two sets is emptyboolean
isZero()
int
length()
Calculates and returns the set's size in bits.void
not()
Logically NOT this bit stringstatic FixedSizeBitVector
not(FixedSizeBitVector s)
Return the NOT of a bit stringvoid
or(FixedSizeBitVector set)
Logically ORs this bit set with the specified set of bits.static FixedSizeBitVector
or(FixedSizeBitVector b1, FixedSizeBitVector b2)
Return a new FixedSizeBitVector as the OR of two othersint
populationCount()
How many bits are set?void
set(int bit)
Sets a bit.void
setAll()
Sets all bits.java.lang.String
toString()
Converts the FixedSizeBitVector to a String.void
xor(FixedSizeBitVector set)
Logically XORs this bit set with the specified set of bits.
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FixedSizeBitVector
public FixedSizeBitVector(int nbits)
Creates an empty string with the specified size.- Parameters:
nbits
- the size of the string
-
FixedSizeBitVector
public FixedSizeBitVector(FixedSizeBitVector s)
Creates a copy of a Bit String- Parameters:
s
- the string to copy- Throws:
java.lang.IllegalArgumentException
- if s is null
-
-
Method Detail
-
setAll
public void setAll()
Sets all bits.
-
set
public void set(int bit)
Sets a bit.- Parameters:
bit
- the bit to be set
-
clearAll
public void clearAll()
Clears all bits.
-
clear
public void clear(int bit)
Clears a bit.- Parameters:
bit
- the bit to be cleared
-
get
public boolean get(int bit)
Gets a bit.- Parameters:
bit
- the bit to be gotten
-
not
public void not()
Logically NOT this bit string
-
not
public static FixedSizeBitVector not(FixedSizeBitVector s)
Return the NOT of a bit string
-
and
public void and(FixedSizeBitVector set)
Logically ANDs this bit set with the specified set of bits.- Parameters:
set
- the bit set to be ANDed with
-
and
public static FixedSizeBitVector and(FixedSizeBitVector b1, FixedSizeBitVector b2)
Return a new bit string as the AND of two others.
-
or
public void or(FixedSizeBitVector set) throws java.lang.IllegalArgumentException
Logically ORs this bit set with the specified set of bits.- Parameters:
set
- the bit set to be ORed with- Throws:
java.lang.IllegalArgumentException
- if set == null
-
or
public static FixedSizeBitVector or(FixedSizeBitVector b1, FixedSizeBitVector b2) throws java.lang.IllegalArgumentException
Return a new FixedSizeBitVector as the OR of two others- Throws:
java.lang.IllegalArgumentException
- if b2 == null
-
xor
public void xor(FixedSizeBitVector set)
Logically XORs this bit set with the specified set of bits.- Parameters:
set
- the bit set to be XORed with- Throws:
java.lang.IllegalArgumentException
- if set is null
-
intersectionEmpty
public boolean intersectionEmpty(FixedSizeBitVector other)
Check if the intersection of the two sets is empty- Parameters:
other
- the set to check intersection with
-
copyBits
public void copyBits(FixedSizeBitVector set)
Copies the values of the bits in the specified set into this set.- Parameters:
set
- the bit set to copy the bits from- Throws:
java.lang.IllegalArgumentException
- if set is null
-
hashCode
public int hashCode()
Gets the hashcode.- Overrides:
hashCode
in classjava.lang.Object
-
populationCount
public int populationCount()
How many bits are set?
-
length
public int length()
Calculates and returns the set's size in bits. The maximum element in the set is the size - 1st element.
-
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.
-
isZero
public boolean isZero()
-
clone
public java.lang.Object clone()
Clones the FixedSizeBitVector.- Overrides:
clone
in classjava.lang.Object
-
toString
public java.lang.String toString()
Converts the FixedSizeBitVector to a String.- Overrides:
toString
in classjava.lang.Object
-
-