Class CombinedBitSet

  • All Implemented Interfaces:
    Accountable, Bits

    public final class CombinedBitSet
    extends BitSet
    implements Bits
    A BitSet implementation that combines two instances of BitSet and Bits to provide a single merged view.
    • Constructor Detail

      • CombinedBitSet

        public CombinedBitSet​(BitSet first,
                              Bits second)
    • Method Detail

      • getFirst

        public BitSet getFirst()
      • cardinality

        public int cardinality()
        This implementation is slow and requires to iterate over all bits to compute the intersection. Use approximateCardinality() for a fast approximation.
        Specified by:
        cardinality in class BitSet
      • approximateCardinality

        public int approximateCardinality()
        Description copied from class: BitSet
        Return an approximation of the cardinality of this set. Some implementations may trade accuracy for speed if they have the ability to estimate the cardinality of the set without iterating over all the data. The default implementation returns BitSet.cardinality().
        Overrides:
        approximateCardinality in class BitSet
      • prevSetBit

        public int prevSetBit​(int index)
        Description copied from class: BitSet
        Returns the index of the last set bit before or on the index specified. -1 is returned if there are no more set bits.
        Specified by:
        prevSetBit in class BitSet
      • nextSetBit

        public int nextSetBit​(int index)
        Description copied from class: BitSet
        Returns the index of the first set bit starting at the index specified. DocIdSetIterator.NO_MORE_DOCS is returned if there are no more set bits.
        Specified by:
        nextSetBit in class BitSet
      • ramBytesUsed

        public long ramBytesUsed()
        Description copied from interface: Accountable
        Return the memory usage of this object in bytes. Negative values are illegal.
        Specified by:
        ramBytesUsed in interface Accountable
      • get

        public boolean get​(int index)
        Description copied from interface: Bits
        Returns the value of the bit with the specified index.
        Specified by:
        get in interface Bits
        Parameters:
        index - index, should be non-negative and < Bits.length(). The result of passing negative or out of bounds values is undefined by this interface, just don't do it!
        Returns:
        true if the bit is set, false otherwise.
      • length

        public int length()
        Description copied from interface: Bits
        Returns the number of bits in this set
        Specified by:
        length in interface Bits
      • set

        public void set​(int i)
        Description copied from class: BitSet
        Set the bit at i.
        Specified by:
        set in class BitSet
      • clear

        public void clear​(int i)
        Description copied from class: BitSet
        Clear the bit at i.
        Specified by:
        clear in class BitSet
      • clear

        public void clear​(int startIndex,
                          int endIndex)
        Description copied from class: BitSet
        Clears a range of bits.
        Specified by:
        clear in class BitSet
        Parameters:
        startIndex - lower index
        endIndex - one-past the last bit to clear