GetPrime() public static method

public static GetPrime ( int min ) : int
min int
return int
Esempio n. 1
0
        public Hashtable(int capacity, float loadFactor)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException("capacity", "NeedNonNegNum");
            }
            if (!(loadFactor >= 0.1f && loadFactor <= 1.0f))
            {
                throw new ArgumentOutOfRangeException("loadFactor", "HashtableLoadFactor");
            }


            this.loadFactor = 0.72f * loadFactor;

            double rawsize = capacity / this.loadFactor;

            if (rawsize > Int32.MaxValue)
            {
                throw new ArgumentException("HTCapacityOverflow");
            }


            int hashsize = (rawsize > InitialSize) ? HashHelpers.GetPrime((int)rawsize) : InitialSize;

            buckets = new bucket[hashsize];

            loadsize           = (int)(this.loadFactor * hashsize);
            isWriterInProgress = false;
        }
        // Token: 0x0600377D RID: 14205 RVA: 0x000D50BC File Offset: 0x000D32BC
        public static int ExpandPrime(int oldSize)
        {
            int num = 2 * oldSize;

            if (num > 2146435069 && 2146435069 > oldSize)
            {
                return(2146435069);
            }
            return(HashHelpers.GetPrime(num));
        }
Esempio n. 3
0
        public static int ExpandPrime(int oldSize)
        {
            int min = 2 * oldSize;

            if ((uint)min > 2146435069U && 2146435069 > oldSize)
            {
                return(2146435069);
            }
            return(HashHelpers.GetPrime(min));
        }
Esempio n. 4
0
        public Hashtable(int capacity, float loadFactor)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            }
            if ((loadFactor < 0.1f) || (loadFactor > 1f))
            {
                throw new ArgumentOutOfRangeException("loadFactor", Environment.GetResourceString("ArgumentOutOfRange_HashtableLoadFactor", new object[] { 0.1, 1.0 }));
            }
            this.loadFactor = 0.72f * loadFactor;
            double num = ((float)capacity) / this.loadFactor;

            if (num > 2147483647.0)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_HTCapacityOverflow"));
            }
            int num2 = (num > 3.0) ? HashHelpers.GetPrime((int)num) : 3;

            this.buckets            = new bucket[num2];
            this.loadsize           = (int)(this.loadFactor * num2);
            this.isWriterInProgress = false;
        }
Esempio n. 5
0
        public Hashtable(int capacity, float loadFactor)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException("capacity", "Non-negative number required.");
            }
            if ((loadFactor < 0.1f) || (loadFactor > 1f))
            {
                throw new ArgumentOutOfRangeException("loadFactor", "Load factor needs to be between 0.1 and 1.0.");
            }
            this.loadFactor = 0.72f * loadFactor;
            double num = ((float)capacity) / this.loadFactor;

            if (num > 2147483647.0)
            {
                throw new ArgumentException("Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.");
            }
            int num2 = (num > 3.0) ? HashHelpers.GetPrime((int)num) : 3;

            this.buckets            = new bucket[num2];
            this.loadsize           = (int)(this.loadFactor * num2);
            this.isWriterInProgress = false;
        }
Esempio n. 6
0
        private void expand()
        {
            int prime = HashHelpers.GetPrime(this.buckets.Length * 2);

            this.rehash(prime);
        }