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; }
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; }
public HashTable(int initCapacity) { this.initCapacity = initCapacity; this.hashTableInternal = new HashTableInternal <TKey, TValue>(this.initCapacity); }