Class JBitSet


  • public final class JBitSet
    extends java.lang.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 java.util.BitSet bitSet  
      private int size  
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void and​(JBitSet set)  
      void clear​(int bitIndex)  
      void clearAll()
      Clear all of the bits in this JBitSet
      java.lang.Object clone()  
      boolean contains​(JBitSet jBitSet)
      Test to see if one JBitSet contains another one of the same size.
      boolean equals​(java.lang.Object obj)  
      boolean get​(int bitIndex)  
      int getFirstSetBit()
      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 hashCode()  
      boolean hasSingleBitSet()
      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 size()
      Return the size of bitSet
      java.lang.String toString()  
      void xor​(JBitSet set)  
      • Methods inherited from class java.lang.Object

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

      • bitSet

        private final java.util.BitSet bitSet
      • size

        private int size
    • Constructor Detail

      • JBitSet

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

        private JBitSet​(java.util.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 Detail

      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.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