Esempio n. 1
0
        public Object Clone()
        {
            Contract.Ensures(Contract.Result <Object>() != null);
            Contract.Ensures(((LazinatorBitArray)Contract.Result <Object>()).Length == this.Length);

            LazinatorBitArray lazinatorBitArray = new LazinatorBitArray(IntStorage.Span);

            lazinatorBitArray._version = _version;
            lazinatorBitArray.m_length = m_length;
            return(lazinatorBitArray);
        }
Esempio n. 2
0
        /*=========================================================================
        ** Allocates a new BitArray with the same length and bit values as bits.
        **
        ** Exceptions: ArgumentException if bits == null.
        ** =========================================================================*/
        public LazinatorBitArray(LazinatorBitArray lazinatorBits)
        {
            if (lazinatorBits == null)
            {
                throw new ArgumentNullException("lazinatorBits");
            }
            Contract.EndContractBlock();

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

            IntStorage = new Memory <int>(new int[arrayLength]);
            Span <int>         s = IntStorage.Span;
            ReadOnlySpan <int> lazinatorBitsSpan = lazinatorBits.IntStorage.Span;

            m_length = lazinatorBits.m_length;

            lazinatorBitsSpan.CopyTo(s);

            _version = lazinatorBits._version;
        }
Esempio n. 3
0
        /*=========================================================================
        ** Returns a reference to the current instance XORed with value.
        **
        ** Exceptions: ArgumentException if value == null or
        **             value.Length != this.Length.
        ** =========================================================================*/
        public LazinatorBitArray Xor(LazinatorBitArray value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (Length != value.Length)
            {
                throw new ArgumentException("Arg_ArrayLengthsDiffer");
            }
            Contract.EndContractBlock();

            Span <int>         s         = IntStorage.Span;
            ReadOnlySpan <int> valueSpan = value.IntStorage.Span;
            int ints = GetArrayLength(m_length, BitsPerInt32);

            for (int i = 0; i < ints; i++)
            {
                s[i] ^= valueSpan[i];
            }

            _version++;
            return(this);
        }
Esempio n. 4
0
 internal BitArrayEnumeratorSimple(LazinatorBitArray bitarray)
 {
     this.bitarray = bitarray;
     this.index    = -1;
     version       = bitarray._version;
 }