EnsureSize() private method

private EnsureSize ( int newSize ) : void
newSize int
return void
Example #1
0
        private void CommonCopyTo(CommonDictionaryStorage into)
        {
            if (into._buckets == null)
            {
                into._buckets = new Bucket[_buckets.Length];
            }
            else
            {
                int curSize = into._buckets.Length;
                int newSize = (int)((_count + into._count) / Load) + 2;
                while (curSize < newSize)
                {
                    curSize *= ResizeMultiplier;
                }
                into.EnsureSize(curSize);
            }

            if (into._keyType == null)
            {
                into._keyType  = _keyType;
                into._hashFunc = _hashFunc;
                into._eqFunc   = _eqFunc;
            }
            else if (into._keyType != _keyType)
            {
                into.SetHeterogeneousSites();
            }

            for (int i = 0; i < _buckets.Length; i++)
            {
                Bucket curBucket = _buckets[i];

                if (curBucket.Key != null &&
                    curBucket.Key != _removed &&
                    into.AddWorker(into._buckets, curBucket.Key, curBucket.Value, curBucket.HashCode))
                {
                    into._count++;
                }
            }
        }
        private void CommonCopyTo(CommonDictionaryStorage into) {
            if (into._buckets == null) {
                into._buckets = new Bucket[_buckets.Length];
            } else {
                int curSize = into._buckets.Length;
                while (curSize < _count + into._count) {
                    curSize *= ResizeMultiplier;
                }
                into.EnsureSize(curSize);
            }

            if (into._keyType == null) {
                into._keyType = _keyType;
                into._hashFunc = _hashFunc;
                into._eqFunc = _eqFunc;
            } else if (into._keyType != _keyType) {
                SetHeterogeneousSites();
            }

            for (int i = 0; i < _buckets.Length; i++) {
                Bucket curBucket = _buckets[i];
                while (curBucket != null) {
                    if (AddWorker(into._buckets, curBucket.Key, curBucket.Value, curBucket.HashCode)) {
                        into._count++;
                    }
                    curBucket = curBucket.Next;
                }
            }
        }