public void TestAddMulModHash() { var h = new AddMulModHash(new MersenneTwister(1215125)); var list = Enumerable.Range(0, 80000).Select(i => h.ComputeHash((uint)i)).ToList(); var set = new HashSet <uint>(list); Assert.Equal(set.Count(), list.Count()); }
public void TestAddMulModHashBucketCollisions() { var h = new AddMulModHash(new MersenneTwister(1215125)); var maxCollisions = Enumerable.Range(0, 80000) .Select(i => h.ComputeHash((uint)i) % 1000) .GroupBy(i => i, i => 1) .Max(g => g.Count()); Assert.True(maxCollisions < 100); }