Formatting.

This commit is contained in:
Gary Gregory 2020-02-16 15:22:43 -05:00
parent 7d06bd77e9
commit a1ce1c2121
7 changed files with 25 additions and 31 deletions

View File

@ -116,7 +116,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
*/
@Override
public boolean contains(final Hasher hasher) {
verifyHasher( hasher );
verifyHasher(hasher);
final long[] buff = getBits();
final OfInt iter = hasher.getBits(shape);
@ -208,9 +208,8 @@ public abstract class AbstractBloomFilter implements BloomFilter {
for (int i = 0; i < limit; i++) {
result[i] = mine[i] | theirs[i];
}
if (limit<result.length)
{
System.arraycopy(remainder, limit, result, limit, result.length-limit);
if (limit < result.length) {
System.arraycopy(remainder, limit, result, limit, result.length - limit);
}
return BitSet.valueOf(result).cardinality();
}
@ -277,9 +276,8 @@ public abstract class AbstractBloomFilter implements BloomFilter {
for (int i = 0; i < limit; i++) {
result[i] = mine[i] ^ theirs[i];
}
if (limit<result.length)
{
System.arraycopy(remainder, limit, result, limit, result.length-limit);
if (limit < result.length) {
System.arraycopy(remainder, limit, result, limit, result.length - limit);
}
return BitSet.valueOf(result).cardinality();
}

View File

@ -46,13 +46,11 @@ public final class StaticHasher implements Hasher {
* @throws IllegalArgumentException if the hasher function and the shape function are not the same.
*/
public StaticHasher(final Hasher hasher, final Shape shape) {
this( hasher.getBits(shape), shape);
if (
HashFunctionIdentity.COMMON_COMPARATOR.compare(
hasher.getHashFunctionIdentity(), shape.getHashFunctionIdentity()) != 0) {
this(hasher.getBits(shape), shape);
if (HashFunctionIdentity.COMMON_COMPARATOR.compare(hasher.getHashFunctionIdentity(),
shape.getHashFunctionIdentity()) != 0) {
throw new IllegalArgumentException(String.format("Hasher (%s) is not the same as for shape (%s)",
HashFunctionIdentity.asCommonString( hasher.getHashFunctionIdentity()),
shape.toString()));
HashFunctionIdentity.asCommonString(hasher.getHashFunctionIdentity()), shape.toString()));
}
}
@ -65,20 +63,18 @@ public final class StaticHasher implements Hasher {
public StaticHasher(final Iterator<Integer> iter, final Shape shape) {
this.shape = shape;
final Set<Integer> workingValues = new TreeSet<>();
iter.forEachRemaining( idx -> {
if (idx >= this.shape.getNumberOfBits())
{
throw new IllegalArgumentException( String.format( "Bit index (%s) is too big for %s", idx, shape ));
iter.forEachRemaining(idx -> {
if (idx >= this.shape.getNumberOfBits()) {
throw new IllegalArgumentException(String.format("Bit index (%s) is too big for %s", idx, shape));
}
if (idx < 0 ) {
throw new IllegalArgumentException( String.format( "Bit index (%s) may not be less than zero", idx ));
if (idx < 0) {
throw new IllegalArgumentException(String.format("Bit index (%s) may not be less than zero", idx));
}
workingValues.add( idx );
workingValues.add(idx);
});
this.values = new int[workingValues.size()];
int i=0;
for (final Integer value : workingValues)
{
int i = 0;
for (final Integer value : workingValues) {
values[i++] = value.intValue();
}
}
@ -114,7 +110,7 @@ public final class StaticHasher implements Hasher {
throw new IllegalArgumentException(
String.format("shape (%s) does not match internal shape (%s)", shape, this.shape));
}
return Arrays.stream( values ).iterator();
return Arrays.stream(values).iterator();
}
@Override

View File

@ -59,9 +59,9 @@ public final class MD5Cyclic implements HashFunction {
try {
messageDigest = MessageDigest.getInstance(NAME);
} catch (final NoSuchAlgorithmException e) {
throw new IllegalStateException( e.getMessage() );
throw new IllegalStateException(e.getMessage());
}
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
}
@Override

View File

@ -49,7 +49,7 @@ public final class Murmur128x86Cyclic implements HashFunction {
* Constructs a Murmur3 x64 128 hash.
*/
public Murmur128x86Cyclic() {
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
}

View File

@ -45,7 +45,7 @@ public final class Murmur32x86Iterative implements HashFunction {
* Constructs a Murmur3 x86 32 hash
*/
public Murmur32x86Iterative() {
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
}
@Override

View File

@ -53,7 +53,7 @@ public final class ObjectsHashIterative implements HashFunction {
* Constructs a hash that uses the Objects.hash method to has values.
*/
public ObjectsHashIterative() {
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
}
@Override
@ -61,7 +61,7 @@ public final class ObjectsHashIterative implements HashFunction {
if (seed == 0) {
last = 0;
}
final long result = Arrays.deepHashCode( new Object[] {last, buffer});
final long result = Arrays.deepHashCode(new Object[] { last, buffer });
last += result;
return result;
}