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); }
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)); } }
/*========================================================================= ** 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; }
/*========================================================================= ** 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); }
internal BitArrayEnumeratorSimple(BitArrayFast bitarray) { this.bitarray = bitarray; this.index = -1; version = bitarray._version; }
public static bool GetFast(this BitArrayFast bitArray, int index) { return((bitArray.m_array[index / 32] & (1 << (index % 32))) != 0); }