示例#1
0
        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());
        }
示例#2
0
        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);
        }