Bits (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util, interface: Bits

Package org.apache.lucene.util

# Interface Bits

All Known Subinterfaces:
  `LiveDocs`

All Known Implementing Classes:
  `Bits.MatchAllBits`, `Bits.MatchNoBits`, `BitSet`, `DenseLiveDocs`, `FixedBitSet`, `MultiBits`, `SparseFixedBitSet`, `SparseLiveDocs`

public interface Bits
Interface for Bitset-like structures.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `Bits.MatchAllBits`
  Bits impl of the specified length with all bits set.
  `static class`
  `Bits.MatchNoBits`
  Bits impl of the specified length with no bits set.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Bits[]`
  `EMPTY_ARRAY`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `applyMask(FixedBitSet bitSet, int offset)`
  Apply this `Bits` instance to the given `FixedBitSet`, which starts at the given `offset`.
  `boolean`
  `get(int index)`
  Returns the value of the bit with the specified `index`.
  `int`
  `length()`
  Returns the number of bits in this set

- ## Field Details

  - ### EMPTY_ARRAY

    static final Bits[] EMPTY_ARRAY

- ## Method Details

  - ### get

    boolean get(int index)
    Returns the value of the bit with the specified `index`.
    Parameters:
      `index` - index, should be non-negative and < `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

    int length()
    Returns the number of bits in this set

  - ### applyMask

    default void applyMask(FixedBitSet bitSet, int offset)
    Apply this `Bits` instance to the given `FixedBitSet`, which starts at the given `offset`.

    This should behave the same way as the default implementation, which does the following:

         for (int i = bitSet.nextSetBit(0);
             i != DocIdSetIterator.NO_MORE_DOCS;
             i = i + 1 >= bitSet.length() ? DocIdSetIterator.NO_MORE_DOCS : bitSet.nextSetBit(i + 1)) {
           if (get(offset + i) == false) {
             bitSet.clear(i);
           }
         }