001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.collections4.bloomfilter;
018
019/**
020 * A Hasher creates {@link IndexExtractor}s based on the hash implementation and the provided {@link Shape}.
021 *
022 * @since 4.5.0-M1
023 */
024public interface Hasher {
025
026    /**
027     * Creates an IndexExtractor for this hasher based on the Shape.
028     *
029     * <p>
030     * The {@code IndexExtractor} will create indices within the range defined by the number of bits in the shape. The total number of indices will respect the
031     * number of hash functions per item defined by the shape. However the count of indices may not be a multiple of the number of hash functions if the
032     * implementation has removed duplicates.
033     * </p>
034     *
035     * <p>
036     * This IndexExtractor must be deterministic in that it must return the same indices for the same Shape.
037     * </p>
038     *
039     * <p>
040     * No guarantee is made as to order of indices.
041     * </p>
042     * <p>
043     * Duplicates indices for a single item may be produced.
044     * </p>
045     *
046     * @param shape the shape of the desired Bloom filter.
047     * @return the iterator of integers
048     */
049    IndexExtractor indices(Shape shape);
050}