Пример #1
0
        public Object Clone()
        {
            Contract.Ensures(Contract.Result <Object>() != null);
            Contract.Ensures(((BitArrayFast)Contract.Result <Object>()).Length == this.Length);

            BitArrayFast bitArray = new BitArrayFast(m_array);

            bitArray._version = _version;
            bitArray.m_length = m_length;
            return(bitArray);
        }
Пример #2
0
 public static void SetFast(this BitArrayFast bitArray, int index, bool value)
 {
     if (value)
     {
         bitArray.m_array[index / 32] |= (1 << (index % 32));
     }
     else
     {
         bitArray.m_array[index / 32] &= ~(1 << (index % 32));
     }
 }
Пример #3
0
        /*=========================================================================
        ** Allocates a new BitArray with the same length and bit values as bits.
        **
        ** Exceptions: ArgumentException if bits == null.
        ** =========================================================================*/
        public BitArrayFast(BitArrayFast bits)
        {
            if (bits == null)
            {
                throw new ArgumentNullException("bits");
            }
            Contract.EndContractBlock();

            int arrayLength = GetArrayLength(bits.m_length, BitsPerInt32);

            m_array  = new int[arrayLength];
            m_length = bits.m_length;

            Array.Copy(bits.m_array, m_array, arrayLength);

            _version = bits._version;
        }
Пример #4
0
        /*=========================================================================
        ** Returns a reference to the current instance XORed with value.
        **
        ** Exceptions: ArgumentException if value == null or
        **             value.Length != this.Length.
        ** =========================================================================*/
        public BitArrayFast Xor(BitArrayFast value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (Length != value.Length)
            {
                throw new ArgumentException("Arg_ArrayLengthsDiffer");
            }
            Contract.EndContractBlock();

            int ints = GetArrayLength(m_length, BitsPerInt32);

            for (int i = 0; i < ints; i++)
            {
                m_array[i] ^= value.m_array[i];
            }

            _version++;
            return(this);
        }
Пример #5
0
 internal BitArrayEnumeratorSimple(BitArrayFast bitarray)
 {
     this.bitarray = bitarray;
     this.index    = -1;
     version       = bitarray._version;
 }
Пример #6
0
 public static bool GetFast(this BitArrayFast bitArray, int index)
 {
     return((bitArray.m_array[index / 32] & (1 << (index % 32))) != 0);
 }