Class JBitSet

java.lang.Object
org.apache.derby.iapi.util.JBitSet

public final class JBitSet extends Object
JBitSet is a wrapper class for BitSet. It is a fixed length implementation which can be extended via the grow() method. It provides additional methods to manipulate BitSets. NOTE: JBitSet was driven by the (current and perceived) needs of the optimizer, but placed in the util package since it is not specific to query trees.. NOTE: java.util.BitSet is final, so we must provide a wrapper class which includes a BitSet member in order to extend the functionality. We want to make it look like JBitSet extends BitSet, so we need to provide wrapper methods for all of BitSet's methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final BitSet
     
    private int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    JBitSet(int size)
    Construct a JBitSet of the specified size.
    private
    JBitSet(BitSet bitSet, int size)
    Construct a JBitSet with the specified bitSet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    and(JBitSet set)
     
    void
    clear(int bitIndex)
     
    void
    Clear all of the bits in this JBitSet
     
    boolean
    contains(JBitSet jBitSet)
    Test to see if one JBitSet contains another one of the same size.
    boolean
     
    boolean
    get(int bitIndex)
     
    int
    Get the first set bit (starting at index 0) from a JBitSet.
    void
    grow(int newSize)
    Grow an existing JBitSet to the specified size.
    int
     
    boolean
    See of a JBitSet has exactly 1 bit set.
    void
    or(JBitSet set)
     
    void
    set(int bitIndex)
     
    void
    setTo(JBitSet sourceBitSet)
    Set the BitSet to have the exact same bits set as the parameter's BitSet.
    int
    Return the size of bitSet
     
    void
    xor(JBitSet set)
     

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • bitSet

      private final BitSet bitSet
    • size

      private int size
  • Constructor Details

    • JBitSet

      public JBitSet(int size)
      Construct a JBitSet of the specified size.
      Parameters:
      size - The number of bits in the JBitSet.
    • JBitSet

      private JBitSet(BitSet bitSet, int size)
      Construct a JBitSet with the specified bitSet.
      Parameters:
      bitSet - The BitSet.
      size - The size of bitSet. NOTE: We need to specify the size since the size of a BitSet is not guaranteed to be the same as JBitSet.size().
  • Method Details

    • setTo

      public void setTo(JBitSet sourceBitSet)
      Set the BitSet to have the exact same bits set as the parameter's BitSet.
      Parameters:
      sourceBitSet - The JBitSet to copy.
    • contains

      public boolean contains(JBitSet jBitSet)
      Test to see if one JBitSet contains another one of the same size.
      Parameters:
      jBitSet - JBitSet that we want to know if it is a subset of current JBitSet
      Returns:
      boolean Whether or not jBitSet is a subset.
    • hasSingleBitSet

      public boolean hasSingleBitSet()
      See of a JBitSet has exactly 1 bit set.
      Returns:
      boolean Whether or not JBitSet has a single bit set.
    • getFirstSetBit

      public int getFirstSetBit()
      Get the first set bit (starting at index 0) from a JBitSet.
      Returns:
      int Index of first set bit, -1 if none set.
    • grow

      public void grow(int newSize)
      Grow an existing JBitSet to the specified size.
      Parameters:
      newSize - The new size
    • clearAll

      public void clearAll()
      Clear all of the bits in this JBitSet
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • get

      public boolean get(int bitIndex)
    • set

      public void set(int bitIndex)
    • clear

      public void clear(int bitIndex)
    • and

      public void and(JBitSet set)
    • or

      public void or(JBitSet set)
    • xor

      public void xor(JBitSet set)
    • size

      public int size()
      Return the size of bitSet
      Returns:
      int Size of bitSet