Esempio n. 1
0
        public void NextClosestPrimeLargeNumber()
        {
            var number       = 10094;
            var closestPrime = 10099;

            var actualResult = PrimeGenerator.GetNextClosestPrime(number);

            Assert.IsTrue(actualResult == closestPrime);
        }
Esempio n. 2
0
        private void ResizeHashTable()
        {
            var closestPrime = PrimeGenerator.GetNextClosestPrime(_buckets.Length * 2);
            var oldBuckets   = _buckets;

            _buckets = new LinkedList <Tuple <int, T> > [closestPrime];
            InitializeBuckets();

            foreach (var bucket in oldBuckets)
            {
                foreach (var tuple in bucket)
                {
                    var newBucket = GetBucket(tuple.Item1);
                    newBucket.AddFirst(tuple);
                }
            }
        }