Exemple #1
0
        public HashTable(int initCapacity, double whenEnlarge, double enlargeRatio)
        {
            this.initCapacity      = initCapacity;
            this.hashTableInternal = new HashTableInternal <TKey, TValue>(this.initCapacity);

            this.whenEnlarge  = whenEnlarge;
            this.enlargeRatio = enlargeRatio;
        }
Exemple #2
0
        private void EnlargeCapacity()
        {
            int oldCapacity = this.hashTableInternal.Capacity;

            int increament = (int)(oldCapacity * enlargeRatio);

            if (increament == 0)
            {
                increament = 1;
            }

            int newCapacity = oldCapacity + increament;

            var newHashTableInternal = new HashTableInternal <TKey, TValue>(newCapacity);

            foreach (var pair in this.hashTableInternal)
            {
                newHashTableInternal.Add(pair.Key, pair.Value);
            }

            this.hashTableInternal = newHashTableInternal;
        }
Exemple #3
0
 public HashTable(int initCapacity)
 {
     this.initCapacity      = initCapacity;
     this.hashTableInternal = new HashTableInternal <TKey, TValue>(this.initCapacity);
 }