Class IndexFilter

java.lang.Object
org.apache.commons.collections4.bloomfilter.IndexFilter

public final class IndexFilter extends Object
A convenience class for Hasher implementations to filter out duplicate indices.

If the index is negative the behavior is not defined.

This is conceptually a unique filter implemented as an IntPredicate.

Since:
4.5.0-M1
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    An IndexTracker implementation that uses an array of integers to track whether or not a number has been seen.
    (package private) static class 
    An IndexTracker implementation that uses an array of bit maps to track whether or not a number has been seen.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final IntPredicate
     
    private final int
     
    private final IntPredicate
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    IndexFilter(Shape shape, IntPredicate consumer)
    Creates an instance optimized for the specified shape.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(Shape shape, IntPredicate consumer)
    Creates an instance optimized for the specified shape.
    boolean
    test(int number)
    Test if the number should be processed by the consumer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • tracker

      private final IntPredicate tracker
    • size

      private final int size
    • consumer

      private final IntPredicate consumer
  • Constructor Details

    • IndexFilter

      private IndexFilter(Shape shape, IntPredicate consumer)
      Creates an instance optimized for the specified shape.
      Parameters:
      shape - The shape that is being generated.
      consumer - The consumer to accept the values.
  • Method Details

    • create

      public static IntPredicate create(Shape shape, IntPredicate consumer)
      Creates an instance optimized for the specified shape.
      Parameters:
      shape - The shape that is being generated.
      consumer - The consumer to accept the values.
      Returns:
      an IndexFilter optimized for the specified shape.
    • test

      public boolean test(int number)
      Test if the number should be processed by the consumer.

      If the number has not been seen before it is passed to the consumer and the result returned. If the number has been seen before the consumer is not called and true returned.

      If the input is not in the range [0,size) an IndexOutOfBoundsException exception is thrown.

      Parameters:
      number - the number to check.
      Returns:
      true if processing should continue, false otherwise.