Claudenw commented on code in PR #317: URL: https://github.com/apache/commons-collections/pull/317#discussion_r914490496
########## src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java: ########## @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections4.bloomfilter; + +import java.util.function.IntPredicate; + +/** + * A convenience class for Hasher implementations to filter out duplicate indices. + * + * <p><em>If the index is negative the behavior is not defined.</em></p> + * + * <p>This is conceptually a unique filter implemented as a {@code IntPredicate}.</p> + * @since 4.5 + */ +public final class IndexFilter implements IntPredicate { + private final IntPredicate tracker; + private final int size; + private final IntPredicate consumer; + + /** + * Creates an instance optimized for the specified shape. + * @param shape The shape that is being generated. + * @param consumer The consumer to accept the values. + * @return an IndexFilter optimized for the specified shape. + */ + public static IndexFilter create(Shape shape, IntPredicate consumer) { Review Comment: Changing to returning the IntPredicate means that the test code can not test the selection of the tracker type. Is this acceptable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
