示例#1
0
        public HashTable(int initialCapacity)
        {
            if (initialCapacity < 1)
            {
                throw new ArgumentException("Invalid initial capacity.");
            }

            array = new HashTableArray <K, V>(initialCapacity);
            maxItemsAtCurrentSize = (int)(initialCapacity * fillFactor) + 1;
        }
示例#2
0
        private void GrowArray()
        {
            HashTableArray <K, V> largerArray = new HashTableArray <K, V>(array.Capacity * 2);

            foreach (var node in array.Items)
            {
                if (node != null)
                {
                    largerArray.Add(node.Key, node.Value);
                }
            }

            array = largerArray;
            maxItemsAtCurrentSize = (int)(array.Capacity * fillFactor) + 1;
        }