Make Hasher test classes package-private
This commit is contained in:
parent
d7343b729c
commit
9582007123
|
@ -22,10 +22,10 @@ import java.util.function.IntPredicate;
|
|||
/**
|
||||
* A Testing Hasher that returns the array values % shape.getNumberOfBits().
|
||||
*
|
||||
* @since 4.5
|
||||
* <p>To be used for testing only.</p>
|
||||
*/
|
||||
public final class ArrayHasher implements Hasher {
|
||||
final int[] values;
|
||||
final class ArrayHasher implements Hasher {
|
||||
private final int[] values;
|
||||
|
||||
ArrayHasher(final int... values) {
|
||||
this.values = values;
|
||||
|
@ -39,6 +39,7 @@ public final class ArrayHasher implements Hasher {
|
|||
|
||||
@Override
|
||||
public IndexProducer uniqueIndices(Shape shape) {
|
||||
Objects.requireNonNull(shape, "shape");
|
||||
return new Producer(shape);
|
||||
}
|
||||
|
||||
|
@ -51,8 +52,10 @@ public final class ArrayHasher implements Hasher {
|
|||
|
||||
@Override
|
||||
public boolean forEachIndex(IntPredicate consumer) {
|
||||
Objects.requireNonNull(consumer, "consumer");
|
||||
|
||||
int pos = 0;
|
||||
for (int i=0; i<shape.getNumberOfHashFunctions(); i++) {
|
||||
for (int i = 0; i < shape.getNumberOfHashFunctions(); i++) {
|
||||
int result = values[pos++] % shape.getNumberOfBits();
|
||||
pos = pos % values.length;
|
||||
if (!consumer.test(result)) {
|
||||
|
|
|
@ -24,10 +24,8 @@ import java.util.function.IntPredicate;
|
|||
* <a href="https://www.eecs.harvard.edu/~michaelm/postscripts/tr-02-05.pdf">Krisch and Mitzenmacher</a>.
|
||||
*
|
||||
* <p>To be used for testing only.</p>
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
class IncrementingHasher implements Hasher {
|
||||
final class IncrementingHasher implements Hasher {
|
||||
|
||||
/**
|
||||
* The initial hash value.
|
||||
|
|
|
@ -22,23 +22,30 @@ import java.util.function.IntPredicate;
|
|||
/**
|
||||
* A Hasher that returns no values.
|
||||
*
|
||||
* @since 4.5
|
||||
* <p>To be used for testing only.</p>
|
||||
*/
|
||||
public final class NullHasher implements Hasher {
|
||||
final class NullHasher implements Hasher {
|
||||
|
||||
/**
|
||||
* The instance of the Null Hasher.
|
||||
*/
|
||||
public static final NullHasher INSTANCE = new NullHasher();
|
||||
static final NullHasher INSTANCE = new NullHasher();
|
||||
|
||||
private static final IndexProducer PRODUCER = new IndexProducer() {
|
||||
@Override
|
||||
public boolean forEachIndex(IntPredicate consumer) {
|
||||
Objects.requireNonNull(consumer, "consumer");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] asIndexArray() {
|
||||
return new int[0];
|
||||
}
|
||||
};
|
||||
|
||||
private NullHasher() {
|
||||
// No instances
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,6 +56,7 @@ public final class NullHasher implements Hasher {
|
|||
|
||||
@Override
|
||||
public IndexProducer uniqueIndices(Shape shape) {
|
||||
Objects.requireNonNull(shape, "shape");
|
||||
return PRODUCER;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue