garydgregory commented on code in PR #501:
URL:
https://github.com/apache/commons-collections/pull/501#discussion_r1635187971
##########
src/main/java/org/apache/commons/collections4/bloomfilter/EnhancedDoubleHasher.java:
##########
@@ -167,41 +167,33 @@ public boolean processIndices(final IntPredicate
consumer) {
// hash[i] = ( h1(x) - i*h2(x) - (i*i*i - i)/6 ) wrapped in
[0, bits)
int index = BitMaps.mod(initial, bits);
+ if (!consumer.test(index)) {
+ return false;
+ }
int inc = BitMaps.mod(increment, bits);
final int k = shape.getNumberOfHashFunctions();
- if (k > bits) {
- for (int j = k; j > 0;) {
- // handle k > bits
- final int block = Math.min(j, bits);
- j -= block;
- for (int i = 1; i <= block; i++) {
- if (!consumer.test(index)) {
- return false;
- }
- // Update index and handle wrapping
- index -= inc;
- index = index < 0 ? index + bits : index;
-
- // Incorporate the counter into the increment to
create a
- // tetrahedral number additional term, and handle
wrapping.
- inc -= i;
- inc = inc < 0 ? inc + bits : inc;
- }
+
+ // the tetraheadral incrementer. We need to ensure that this
+ // number does not exceed bits-1 or we may end up with an
index > bits.
+ int tet = 1;
+ for (int i = 1; i < k; i++) {
+ // Update index and handle wrapping
+ index -= inc;
+ index = index < 0 ? index + bits : index;
+ if (!consumer.test(index)) {
+ return false;
+ }
+
+ // Incorporate the counter into the increment to create a
+ // tetrahedral number additional term, and handle wrapping.
+ inc -= tet;
+ inc = inc < 0 ? inc + bits : inc;
+ if (inc >= bits) {
+ inc = BitMaps.mod(increment, bits);
Review Comment:
I assume this PR is not ready then?
--
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]