static void assertIndependentHashers(HashFunction hashFunction) { int numActions = 100; // hashcodes from non-overlapping hash computations HashCode expected1 = randomHash(hashFunction, new Random(1L), numActions); HashCode expected2 = randomHash(hashFunction, new Random(2L), numActions); // equivalent, but overlapping, computations (should produce the same results as above) Random random1 = new Random(1L); Random random2 = new Random(2L); Hasher hasher1 = hashFunction.newHasher(); Hasher hasher2 = hashFunction.newHasher(); for (int i = 0; i < numActions; i++) { RandomHasherAction.pickAtRandom(random1).performAction(random1, ImmutableSet.of(hasher1)); RandomHasherAction.pickAtRandom(random2).performAction(random2, ImmutableSet.of(hasher2)); } Assert.assertEquals(expected1, hasher1.hash()); Assert.assertEquals(expected2, hasher2.hash()); }
static void assertIndependentHashers(HashFunction hashFunction) { int numActions = 100; // hashcodes from non-overlapping hash computations HashCode expected1 = randomHash(hashFunction, new Random(1L), numActions); HashCode expected2 = randomHash(hashFunction, new Random(2L), numActions); // equivalent, but overlapping, computations (should produce the same results as above) Random random1 = new Random(1L); Random random2 = new Random(2L); Hasher hasher1 = hashFunction.newHasher(); Hasher hasher2 = hashFunction.newHasher(); for (int i = 0; i < numActions; i++) { RandomHasherAction.pickAtRandom(random1).performAction(random1, ImmutableSet.of(hasher1)); RandomHasherAction.pickAtRandom(random2).performAction(random2, ImmutableSet.of(hasher2)); } Assert.assertEquals(expected1, hasher1.hash()); Assert.assertEquals(expected2, hasher2.hash()); }