Esempio n. 1
0
        public KeyGroupMeta(TCompare comparer, int capacity = 7)
        {
            this.comparer = comparer;

            Vals      = new GroupBuffer <TVal> [capacity];
            Keys      = new TKey[capacity];
            HashCodes = new int[capacity];
            GroupUtility.Memset(HashCodes, 0);
            Nexts   = new int[capacity];
            buckets = new int[capacity];

            freeList = -1;
            count    = 0;
        }
Esempio n. 2
0
        private void Resize()
        {
            var length   = checked (count * 2 + 1);
            var numArray = new int[length];

            var newVals = new GroupBuffer <TVal> [length];

            Array.Copy(Vals, 0, newVals, 0, count);
            Vals = newVals;

            var newKeys = new TKey[length];

            Array.Copy(Keys, 0, newKeys, 0, count);
            Keys = newKeys;

            var newHashLists = new int[length];

            Array.Copy(HashCodes, 0, newHashLists, 0, count);
            HashCodes = newHashLists;
            GroupUtility.Memset(HashCodes, (uint)count);

            var newNexts = new int[length];

            Array.Copy(Nexts, 0, newNexts, 0, count);
            Nexts = newNexts;

            unsafe
            {
                fixed(int *pointNumArr = numArray, ptrHash = HashCodes, ptrNexts = Nexts)
                {
                    for (var index1 = 0u; index1 < (uint)count; ++index1)
                    {
                        var index2 = ptrHash[index1] % length;
                        ptrNexts[index1]    = pointNumArr[index2] - 1;
                        pointNumArr[index2] = (int)(index1 + 1);
                    }
                }
            }

            buckets = numArray;
        }