Package org.apache.commons.collections4.bloomfilter

# Interface IndexExtractor

All Known Subinterfaces:
  `BloomFilter<T>`, `CellExtractor`, `CountingBloomFilter`

All Known Implementing Classes:
  `ArrayCountingBloomFilter`, `LayeredBloomFilter`, `SimpleBloomFilter`, `SparseBloomFilter`, `WrappedBloomFilter`

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IndexExtractor
An object that produces indices of a Bloom filter.

The default implementation of `asIndexArray` is slow. Implementers should reimplement the method where possible.

Since:
  4.5.0-M2

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default int[]`
  `asIndexArray()`
  Return a copy of the IndexExtractor data as an int array.
  `static IndexExtractor`
  `fromBitMapExtractor(BitMapExtractor bitMapExtractor)`
  Creates an IndexExtractor from a `BitMapExtractor`.
  `static IndexExtractor`
  `fromIndexArray(int... values)`
  Creates an IndexExtractor from an array of integers.
  `boolean`
  `processIndices(IntPredicate predicate)`
  Each index is passed to the predicate.
  `default IndexExtractor`
  `uniqueIndices()`
  Creates an IndexExtractor comprising the unique indices for this extractor.

- ## Method Details

  - ### fromBitMapExtractor

    static IndexExtractor fromBitMapExtractor(BitMapExtractor bitMapExtractor)
    Creates an IndexExtractor from a `BitMapExtractor`.
    Parameters:
      `bitMapExtractor` - The `BitMapExtractor`
    Returns:
      A new `IndexExtractor`.

  - ### fromIndexArray

    static IndexExtractor fromIndexArray(int... values)
    Creates an IndexExtractor from an array of integers.
    Parameters:
      `values` - The index values
    Returns:
      An IndexExtractor that uses the values.

  - ### asIndexArray

    default int[] asIndexArray()
    Return a copy of the IndexExtractor data as an int array.

    Indices ordering and uniqueness is not guaranteed.

    The default implementation of this method creates an array and populates it. Implementations that have access to an index array should consider returning a copy of that array if possible.

    Returns:
      An int array of the data.

  - ### processIndices

    boolean processIndices(IntPredicate predicate)
    Each index is passed to the predicate. The predicate is applied to each index value, if the predicate returns `false` the execution is stopped, `false` is returned, and no further indices are processed.

    Any exceptions thrown by the action are relayed to the caller.

    Indices ordering and uniqueness is not guaranteed.

    Parameters:
      `predicate` - The action to be performed for each non-zero bit index.
    Returns:
      `true` if all indexes return true from consumer, `false` otherwise.
    Throws:
      `NullPointerException` - if the specified action is null

  - ### uniqueIndices

    default IndexExtractor uniqueIndices()
    Creates an IndexExtractor comprising the unique indices for this extractor.

    By default creates a new extractor with some overhead to remove duplicates. IndexExtractors that return unique indices by default should override this to return `this`.

    The default implementation will filter the indices from this instance and return them in ascending order.

    Returns:
      The IndexExtractor of unique values.
    Throws:
      `IndexOutOfBoundsException` - if any index is less than zero.