Class AbstractBitSet

java.lang.Object
pascal.taie.util.collection.AbstractBitSet
All Implemented Interfaces:
Serializable, IBitSet, Copyable<IBitSet>
Direct Known Subclasses:
RegularBitSet, SparseBitSet

public abstract class AbstractBitSet extends Object implements IBitSet
Provides common functionality for IBitSet implementations.

Especially, based on IBitSet.Action, it implements some operations on IBitSet without the need to knowing its concrete type, so that it support operations between bit sets of different types.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface pascal.taie.util.collection.IBitSet

    IBitSet.Action<R>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
     
    protected static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
    boolean
    Returns true if this BitSet contains all set bits in the specified BitSet.
    boolean
    Returns false if the specified BitSet has any bits set to true that are also set to true in this BitSet.
    boolean
    Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.
    boolean
    or(IBitSet set)
    Performs a logical OR of this bit set with the bit set argument.
    Performs a logical OR of this bit set with the bit set argument, computes and returns the difference set between given bit set and this set (before performing logical OR).
    boolean
    set(int bitIndex, boolean value)
    Sets the bit at the specified index to the specified value.
    void
    Sets the content of this bit set to the same as specified bit set.
    Returns a string representation of this bit set.
    protected static int
    wordIndex(int bitIndex)
    Given a bit index, return word index containing it.
    boolean
    xor(IBitSet set)
    Performs a logical XOR of this bit set with the bit set argument.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface pascal.taie.util.Copyable

    copy

    Methods inherited from interface pascal.taie.util.collection.IBitSet

    and, cardinality, clear, clear, flip, get, isEmpty, iterateBits, length, nextClearBit, nextSetBit, previousClearBit, previousSetBit, set, size
  • Field Details

  • Constructor Details

    • AbstractBitSet

      public AbstractBitSet()
  • Method Details

    • wordIndex

      protected static int wordIndex(int bitIndex)
      Given a bit index, return word index containing it.
    • set

      public boolean set(int bitIndex, boolean value)
      Description copied from interface: IBitSet
      Sets the bit at the specified index to the specified value.
      Specified by:
      set in interface IBitSet
      Parameters:
      bitIndex - a bit index
      value - a boolean value to set
      Returns:
      true if this BitSet changed as a result of the call
    • intersects

      public boolean intersects(IBitSet set)
      Description copied from interface: IBitSet
      Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.
      Specified by:
      intersects in interface IBitSet
      Parameters:
      set - BitSet to intersect with
      Returns:
      boolean indicating whether this BitSet intersects the specified BitSet
    • disjoints

      public boolean disjoints(IBitSet set)
      Description copied from interface: IBitSet
      Returns false if the specified BitSet has any bits set to true that are also set to true in this BitSet.
      Specified by:
      disjoints in interface IBitSet
      Parameters:
      set - BitSet to disjoint with
      Returns:
      boolean indicating whether this BitSet disjoints the specified BitSet
    • contains

      public boolean contains(IBitSet set)
      Description copied from interface: IBitSet
      Returns true if this BitSet contains all set bits in the specified BitSet.
      Specified by:
      contains in interface IBitSet
      Parameters:
      set - bit set to be checked for containment in this set.
      Returns:
      boolean indicating whether this BitSet contains all set bits in the specified BitSet
    • andNot

      public boolean andNot(IBitSet set)
      Description copied from interface: IBitSet
      Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
      Specified by:
      andNot in interface IBitSet
      Parameters:
      set - the BitSet with which to mask this BitSet
      Returns:
      true if this bit set changed as a result of the call
    • or

      public boolean or(IBitSet set)
      Description copied from interface: IBitSet
      Performs a logical OR of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the bit set argument has the value true.
      Specified by:
      or in interface IBitSet
      Parameters:
      set - a bit set
      Returns:
      true if this bit set changed as a result of the call
    • orDiff

      public IBitSet orDiff(IBitSet set)
      Description copied from interface: IBitSet
      Performs a logical OR of this bit set with the bit set argument, computes and returns the difference set between given bit set and this set (before performing logical OR).
      Specified by:
      orDiff in interface IBitSet
      Parameters:
      set - a bit set.
      Returns:
      a new bit set of bit values that are present in the bit set argument and were absent in this bit set before.
    • xor

      public boolean xor(IBitSet set)
      Description copied from interface: IBitSet
      Performs a logical XOR of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:
      • The bit initially has the value true, and the corresponding bit in the argument has the value false.
      • The bit initially has the value false, and the corresponding bit in the argument has the value true.
      Specified by:
      xor in interface IBitSet
      Parameters:
      set - a bit set
      Returns:
      true if this bit set changed as a result of the call
    • setTo

      public void setTo(IBitSet set)
      Description copied from interface: IBitSet
      Sets the content of this bit set to the same as specified bit set.
      Specified by:
      setTo in interface IBitSet
      Parameters:
      set - a bit set
    • toString

      public String toString()
      Returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.

      Example:

       BitSet drPepper = new BitSet();
      Now drPepper.toString() returns "{}".
       drPepper.set(2);
      Now drPepper.toString() returns "{2}".
       drPepper.set(4);
       drPepper.set(10);
      Now drPepper.toString() returns "{2, 4, 10}".
      Overrides:
      toString in class Object
      Returns:
      a string representation of this bit set