Class IndexFilter
java.lang.Object
org.apache.commons.collections4.bloomfilter.IndexFilter
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 ClassesModifier and TypeClassDescription(package private) static classAn IndexTracker implementation that uses an array of integers to track whether or not a number has been seen.(package private) static classAn IndexTracker implementation that uses an array of bit maps to track whether or not a number has been seen. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IntPredicateprivate final intprivate final IntPredicate -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIndexFilter(Shape shape, IntPredicate consumer) Creates an instance optimized for the specified shape. -
Method Summary
Modifier and TypeMethodDescriptionstatic IntPredicatecreate(Shape shape, IntPredicate consumer) Creates an instance optimized for the specified shape.booleantest(int number) Test if the number should be processed by theconsumer.
-
Field Details
-
tracker
-
size
private final int size -
consumer
-
-
Constructor Details
-
IndexFilter
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
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 theconsumer.If the number has not been seen before it is passed to the
consumerand the result returned. If the number has been seen before theconsumeris not called andtruereturned.If the input is not in the range [0,size) an IndexOutOfBoundsException exception is thrown.
- Parameters:
number- the number to check.- Returns:
trueif processing should continue,falseotherwise.
-