Esempio n. 1
0
        private unsafe void IntersectWithEnumerable(IEnumerable <T> other)
        {
            System.Collections.Generic.BitHelper helper;
            int lastIndex = this.m_lastIndex;
            int length    = System.Collections.Generic.BitHelper.ToIntArrayLength(lastIndex);

            if (length <= 100)
            {
                int *bitArrayPtr = (int *)stackalloc byte[(((IntPtr)length) * 4)];
                helper = new System.Collections.Generic.BitHelper(bitArrayPtr, length);
            }
            else
            {
                int[] bitArray = new int[length];
                helper = new System.Collections.Generic.BitHelper(bitArray, length);
            }
            foreach (T local in other)
            {
                int bitPosition = this.InternalIndexOf(local);
                if (bitPosition >= 0)
                {
                    helper.MarkBit(bitPosition);
                }
            }
            for (int i = 0; i < lastIndex; i++)
            {
                if ((this.m_slots[i].hashCode >= 0) && !helper.IsMarked(i))
                {
                    this.Remove(this.m_slots[i].value);
                }
            }
        }
Esempio n. 2
0
        private unsafe ElementCount <T> CheckUniqueAndUnfoundElements(IEnumerable <T> other, bool returnIfUnfound)
        {
            ElementCount <T> count;

            if (this.m_count != 0)
            {
                System.Collections.Generic.BitHelper helper;
                int length = System.Collections.Generic.BitHelper.ToIntArrayLength(this.m_lastIndex);
                if (length <= 100)
                {
                    int *bitArrayPtr = (int *)stackalloc byte[(((IntPtr)length) * 4)];
                    helper = new System.Collections.Generic.BitHelper(bitArrayPtr, length);
                }
                else
                {
                    int[] bitArray = new int[length];
                    helper = new System.Collections.Generic.BitHelper(bitArray, length);
                }
                int num4 = 0;
                int num5 = 0;
                foreach (T local in other)
                {
                    int bitPosition = this.InternalIndexOf(local);
                    if (bitPosition >= 0)
                    {
                        if (!helper.IsMarked(bitPosition))
                        {
                            helper.MarkBit(bitPosition);
                            num5++;
                        }
                    }
                    else
                    {
                        num4++;
                        if (returnIfUnfound)
                        {
                            break;
                        }
                    }
                }
                count.uniqueCount  = num5;
                count.unfoundCount = num4;
                return(count);
            }
            int num = 0;

            using (IEnumerator <T> enumerator = other.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T current = enumerator.Current;
                    num++;
                    goto Label_0039;
                }
            }
Label_0039:
            count.uniqueCount  = 0;
            count.unfoundCount = num;
            return(count);
        }
Esempio n. 3
0
        private unsafe void SymmetricExceptWithEnumerable(IEnumerable <T> other)
        {
            System.Collections.Generic.BitHelper helper;
            System.Collections.Generic.BitHelper helper2;
            int lastIndex = this.m_lastIndex;
            int length    = System.Collections.Generic.BitHelper.ToIntArrayLength(lastIndex);

            if (length <= 50)
            {
                int *bitArrayPtr = (int *)stackalloc byte[(((IntPtr)length) * 4)];
                helper = new System.Collections.Generic.BitHelper(bitArrayPtr, length);
                int *numPtr2 = (int *)stackalloc byte[(((IntPtr)length) * 4)];
                helper2 = new System.Collections.Generic.BitHelper(numPtr2, length);
            }
            else
            {
                int[] bitArray = new int[length];
                helper = new System.Collections.Generic.BitHelper(bitArray, length);
                int[] numArray2 = new int[length];
                helper2 = new System.Collections.Generic.BitHelper(numArray2, length);
            }
            foreach (T local in other)
            {
                int location = 0;
                if (this.AddOrGetLocation(local, out location))
                {
                    helper2.MarkBit(location);
                }
                else if ((location < lastIndex) && !helper2.IsMarked(location))
                {
                    helper.MarkBit(location);
                }
            }
            for (int i = 0; i < lastIndex; i++)
            {
                if (helper.IsMarked(i))
                {
                    this.Remove(this.m_slots[i].value);
                }
            }
        }