Class BitVector

All Implemented Interfaces:
Serializable, Cloneable

public class BitVector extends BitVectorBase<BitVector>
See Also:
  • 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

      public BitVector(BitVector s)
      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:
      set in class BitVectorBase<BitVector>
      Parameters:
      bit - the bit to be set
    • clear

      public final void clear(int bit)
      Clears a bit.
      Specified by:
      clear in class BitVectorBase<BitVector>
      Parameters:
      bit - the bit to be cleared
    • get

      public final boolean get(int bit)
      Gets a bit.
      Specified by:
      get in class BitVectorBase<BitVector>
      Parameters:
      bit - the bit to be gotten
    • not

      public static BitVector not(BitVector s)
      Return the NOT of a bit string
    • and

      public final void and(BitVector set)
      Logically ANDs this bit set with the specified set of bits.
      Specified by:
      and in class BitVectorBase<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 class BitVectorBase<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.
      Returns:
      the number of bits added to this.
      Throws:
      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 class BitVectorBase<BitVector>
      Parameters:
      set - the bit set to be XORed with
      Throws:
      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 class BitVectorBase<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:
      length in class BitVectorBase<BitVector>
    • sameBits

      public final boolean sameBits(BitVector B)
      Compares this object against the specified object.
      Specified by:
      sameBits in class BitVectorBase<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 class BitVectorBase<BitVector>
      Returns:
      true iff this is a subset of other
    • andNot

      public void andNot(BitVector vector)
      Specified by:
      andNot in class BitVectorBase<BitVector>
    • equals

      public boolean equals(Object obj)
      Compares this object against the specified object.
      Overrides:
      equals in class 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
    • andNot

      public static BitVector andNot(BitVector b1, BitVector b2)
      Return a new bit string as the AND of two others.