Implementation of elastic bit array. The internal array is resized automatically within the set value operation.
示例#1
0
        public static void SetFalse(ref ElasticBitArray array, int index)
        {
            Debug.Assert(array._bits != null);

            var num = index / IntSize;

            if (index >= 0 && num < array._bits.Length)
            {
                array._bits[num] &= ~(1 << index % IntSize);
            }

            // otherwise no value means false
        }
示例#2
0
        public static void SetTrue(ref ElasticBitArray array, int index)
        {
            Debug.Assert(array._bits != null);

            if (index < 0)
            {
                throw new ArgumentException();
            }

            var num = index / IntSize;

            if (num >= array._bits.Length)
            {
                Array.Resize(ref array._bits, (num + 1) * 2);
            }

            array._bits[num] |= 1 << index % IntSize;
        }