private static <T> boolean contains(ByteBuff bloomBuf, int bloomOffset, int bloomSize, Hash hash, int hashCount, HashKey<T> hashKey) { int hash1 = hash.hash(hashKey, 0); int bloomBitSize = bloomSize << 3; int hash2 = 0; int compositeHash = 0; if (randomGeneratorForTest == null) { // Production mode compositeHash = hash1; hash2 = hash.hash(hashKey, hash1); } for (int i = 0; i < hashCount; i++) { int hashLoc = (randomGeneratorForTest == null // Production mode ? Math.abs(compositeHash % bloomBitSize) // Test mode with "fake look-ups" to estimate "ideal false positive rate" : randomGeneratorForTest.nextInt(bloomBitSize)); compositeHash += hash2; if (!checkBit(hashLoc, bloomBuf, bloomOffset)) { return false; } } return true; }