org.apache.lucene.util

## Class DocIdBitSet

- java.lang.Object
- - org.apache.lucene.search.DocIdSet
  - - org.apache.lucene.util.DocIdBitSet

All Implemented Interfaces:
  Bits

    public class DocIdBitSet
    extends DocIdSet
    implements Bits

Simple DocIdSet and DocIdSetIterator backed by a BitSet

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.lucene.util.Bits

`Bits.MatchAllBits, Bits.MatchNoBits`

### Field Summary

### Fields inherited from class org.apache.lucene.search.DocIdSet

`EMPTY_DOCIDSET`

### Fields inherited from interface org.apache.lucene.util.Bits

`EMPTY_ARRAY`

### Constructor Summary

Constructors
Constructor and Description
`DocIdBitSet(BitSet bitSet)`

### Method Summary

Methods
`Bits` `bits()` Optionally provides a `Bits` interface for random access to matching documents.
`boolean` `get(int index)` Returns the value of the bit with the specified `index`.
`BitSet` `getBitSet()` Returns the underlying BitSet.
`boolean` `isCacheable()` This DocIdSet implementation is cacheable.
`DocIdSetIterator` `iterator()` Provides a `DocIdSetIterator` to access the set.
`int` `length()` Returns the number of bits in this set

### Methods inherited from class java.lang.Object

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

### Constructor Detail

#### DocIdBitSet

    public DocIdBitSet(BitSet bitSet)

### Method Detail

#### iterator

    public DocIdSetIterator iterator()

Description copied from class: `DocIdSet`
Provides a `DocIdSetIterator` to access the set. This implementation can return `null` or `DocIdSet.EMPTY_DOCIDSET.iterator()` if there are no docs that match.

Specified by:
  `iterator` in class `DocIdSet`

#### bits

    public Bits bits()

Description copied from class: `DocIdSet`
Optionally provides a `Bits` interface for random access to matching documents.

Overrides:
  `bits` in class `DocIdSet`
Returns:
  `null`, if this `DocIdSet` does not support random access. In contrast to `DocIdSet.iterator()`, a return value of `null` does not imply that no documents match the filter! The default implementation does not provide random access, so you only need to implement this method if your DocIdSet can guarantee random access to every docid in O(1) time without external disk access (as `Bits` interface cannot throw `IOException`). This is generally true for bit sets like `FixedBitSet`, which return itself if they are used as `DocIdSet`.

#### isCacheable

    public boolean isCacheable()

This DocIdSet implementation is cacheable.

Overrides:
  `isCacheable` in class `DocIdSet`

#### getBitSet

    public BitSet getBitSet()

Returns the underlying BitSet.

#### 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`