Skip to content

Commit

Permalink
Use long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Apr 13, 2024
1 parent 2c35b9c commit de05f5f
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ private static int calculateNumberOfHashFunctions(final int numberOfItems, final
// than integer math.
final long k = Math.round(LN_2 * numberOfBits / numberOfItems);
if (k < 1) {
throw new IllegalArgumentException(
String.format("Filter too small: Calculated number of hash functions (%s) was less than 1", k));
throw new IllegalArgumentException(String.format("Filter too small: Calculated number of hash functions (%s) was less than 1", k));
}
// Normally we would check that numberOfHashFunctions <= Integer.MAX_VALUE but
// since numberOfBits is at most Integer.MAX_VALUE the numerator of
Expand Down Expand Up @@ -164,8 +163,7 @@ private static int checkNumberOfBits(final int numberOfBits) {
*/
private static int checkNumberOfHashFunctions(final int numberOfHashFunctions) {
if (numberOfHashFunctions < 1) {
throw new IllegalArgumentException(
"Number of hash functions must be greater than 0: " + numberOfHashFunctions);
throw new IllegalArgumentException("Number of hash functions must be greater than 0: " + numberOfHashFunctions);
}
return numberOfHashFunctions;
}
Expand Down Expand Up @@ -329,8 +327,7 @@ public static Shape fromPMK(final double probability, final int numberOfBits, fi

// Number of items (n):
// n = ceil(m / (-k / ln(1 - exp(ln(p) / k))))
final double n = Math.ceil(numberOfBits
/ (-numberOfHashFunctions / Math.log(-Math.expm1(Math.log(probability) / numberOfHashFunctions))));
final double n = Math.ceil(numberOfBits / (-numberOfHashFunctions / Math.log(-Math.expm1(Math.log(probability) / numberOfHashFunctions))));

// log of probability is always < 0
// number of hash functions is >= 1
Expand Down Expand Up @@ -377,8 +374,7 @@ public boolean equals(final Object obj) {
// Shape is final so no check for the same class as inheritance is not possible
if (obj instanceof Shape) {
final Shape other = (Shape) obj;
return numberOfBits == other.numberOfBits &&
numberOfHashFunctions == other.numberOfHashFunctions;
return numberOfBits == other.numberOfBits && numberOfHashFunctions == other.numberOfHashFunctions;
}
return false;
}
Expand Down Expand Up @@ -462,8 +458,7 @@ public double getProbability(final int numberOfItems) {
if (numberOfItems == 0) {
return 0;
}
return Math.pow(-Math.expm1(-1.0 * numberOfHashFunctions * numberOfItems / numberOfBits),
numberOfHashFunctions);
return Math.pow(-Math.expm1(-1.0 * numberOfHashFunctions * numberOfItems / numberOfBits), numberOfHashFunctions);
}

@Override
Expand Down

0 comments on commit de05f5f

Please sign in to comment.