using System; using System.Runtime.InteropServices; namespace System.Collections { /// Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0). /// 2 // Token: 0x02000121 RID: 289 [ComVisible(true)] [Serializable] public sealed class BitArray : IEnumerable, ICloneable, ICollection { /// Initializes a new instance of the class that contains bit values copied from the specified . /// The to copy. /// /// is null. // Token: 0x06000EFF RID: 3839 RVA: 0x0003F580 File Offset: 0x0003D780 public BitArray(BitArray bits) { if (bits == null) { throw new ArgumentNullException("bits"); } this.m_length = bits.m_length; this.m_array = new int[(this.m_length + 31) / 32]; if (this.m_array.Length == 1) { this.m_array[0] = bits.m_array[0]; } else { Array.Copy(bits.m_array, this.m_array, this.m_array.Length); } } /// Initializes a new instance of the class that contains bit values copied from the specified array of Booleans. /// An array of Booleans to copy. /// /// is null. // Token: 0x06000F00 RID: 3840 RVA: 0x0003F604 File Offset: 0x0003D804 public BitArray(bool[] values) { if (values == null) { throw new ArgumentNullException("values"); } this.m_length = values.Length; this.m_array = new int[(this.m_length + 31) / 32]; for (int i = 0; i < values.Length; i++) { this[i] = values[i]; } } /// Initializes a new instance of the class that contains bit values copied from the specified array of bytes. /// An array of bytes containing the values to copy, where each byte represents eight consecutive bits. /// /// is null. /// The length of is greater than . // Token: 0x06000F01 RID: 3841 RVA: 0x0003F668 File Offset: 0x0003D868 public BitArray(byte[] bytes) { if (bytes == null) { throw new ArgumentNullException("bytes"); } this.m_length = bytes.Length * 8; this.m_array = new int[(this.m_length + 31) / 32]; for (int i = 0; i < bytes.Length; i++) { this.setByte(i, bytes[i]); } } /// Initializes a new instance of the class that contains bit values copied from the specified array of 32-bit integers. /// An array of integers containing the values to copy, where each integer represents 32 consecutive bits. /// /// is null. /// The length of is greater than // Token: 0x06000F02 RID: 3842 RVA: 0x0003F6CC File Offset: 0x0003D8CC public BitArray(int[] values) { if (values == null) { throw new ArgumentNullException("values"); } int num = values.Length; this.m_length = num * 32; this.m_array = new int[num]; Array.Copy(values, this.m_array, num); } /// Initializes a new instance of the class that can hold the specified number of bit values, which are initially set to false. /// The number of bit values in the new . /// /// is less than zero. // Token: 0x06000F03 RID: 3843 RVA: 0x0003F718 File Offset: 0x0003D918 public BitArray(int length) { if (length < 0) { throw new ArgumentOutOfRangeException("length"); } this.m_length = length; this.m_array = new int[(this.m_length + 31) / 32]; } /// Initializes a new instance of the class that can hold the specified number of bit values, which are initially set to the specified value. /// The number of bit values in the new . /// The Boolean value to assign to each bit. /// /// is less than zero. // Token: 0x06000F04 RID: 3844 RVA: 0x0003F75C File Offset: 0x0003D95C public BitArray(int length, bool defaultValue) : this(length) { if (defaultValue) { for (int i = 0; i < this.m_array.Length; i++) { this.m_array[i] = -1; } } } // Token: 0x06000F05 RID: 3845 RVA: 0x0003F798 File Offset: 0x0003D998 private BitArray(int[] array, int length) { this.m_array = array; this.m_length = length; } // Token: 0x06000F06 RID: 3846 RVA: 0x0003F7B0 File Offset: 0x0003D9B0 private byte getByte(int byteIndex) { int num = byteIndex / 4; int num2 = byteIndex % 4 * 8; int num3 = this.m_array[num] & (255 << num2); return (byte)((num3 >> num2) & 255); } // Token: 0x06000F07 RID: 3847 RVA: 0x0003F7E8 File Offset: 0x0003D9E8 private void setByte(int byteIndex, byte value) { int num = byteIndex / 4; int num2 = byteIndex % 4 * 8; this.m_array[num] &= ~(255 << num2); this.m_array[num] |= (int)value << num2; this._version++; } // Token: 0x06000F08 RID: 3848 RVA: 0x0003F844 File Offset: 0x0003DA44 private void checkOperand(BitArray operand) { if (operand == null) { throw new ArgumentNullException(); } if (operand.m_length != this.m_length) { throw new ArgumentException(); } } /// Gets the number of elements contained in the . /// The number of elements contained in the . /// 2 // Token: 0x1700024F RID: 591 // (get) Token: 0x06000F09 RID: 3849 RVA: 0x0003F86C File Offset: 0x0003DA6C public int Count { get { return this.m_length; } } /// Gets a value indicating whether the is read-only. /// This property is always false. /// 2 // Token: 0x17000250 RID: 592 // (get) Token: 0x06000F0A RID: 3850 RVA: 0x0003F874 File Offset: 0x0003DA74 public bool IsReadOnly { get { return false; } } /// Gets a value indicating whether access to the is synchronized (thread safe). /// This property is always false. /// 2 // Token: 0x17000251 RID: 593 // (get) Token: 0x06000F0B RID: 3851 RVA: 0x0003F878 File Offset: 0x0003DA78 public bool IsSynchronized { get { return false; } } /// Gets or sets the value of the bit at a specific position in the . /// The value of the bit at position . /// The zero-based index of the value to get or set. /// /// is less than zero.-or- is equal to or greater than . /// 2 // Token: 0x17000252 RID: 594 public bool this[int index] { get { return this.Get(index); } set { this.Set(index, value); } } /// Gets or sets the number of elements in the . /// The number of elements in the . /// The property is set to a value that is less than zero. /// 2 // Token: 0x17000253 RID: 595 // (get) Token: 0x06000F0E RID: 3854 RVA: 0x0003F894 File Offset: 0x0003DA94 // (set) Token: 0x06000F0F RID: 3855 RVA: 0x0003F89C File Offset: 0x0003DA9C public int Length { get { return this.m_length; } set { if (this.m_length == value) { return; } if (value < 0) { throw new ArgumentOutOfRangeException(); } if (value > this.m_length) { int num = (value + 31) / 32; int num2 = (this.m_length + 31) / 32; if (num > this.m_array.Length) { int[] array = new int[num]; Array.Copy(this.m_array, array, this.m_array.Length); this.m_array = array; } else { Array.Clear(this.m_array, num2, num - num2); } int num3 = this.m_length % 32; if (num3 > 0) { this.m_array[num2 - 1] &= (1 << num3) - 1; } } this.m_length = value; this._version++; } } /// Gets an object that can be used to synchronize access to the . /// An object that can be used to synchronize access to the . /// 2 // Token: 0x17000254 RID: 596 // (get) Token: 0x06000F10 RID: 3856 RVA: 0x0003F96C File Offset: 0x0003DB6C public object SyncRoot { get { return this; } } /// Creates a shallow copy of the . /// A shallow copy of the . /// 2 // Token: 0x06000F11 RID: 3857 RVA: 0x0003F970 File Offset: 0x0003DB70 public object Clone() { return new BitArray(this); } /// Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// /// is multidimensional.-or- The number of elements in the source is greater than the available space from to the end of the destination . /// The type of the source cannot be cast automatically to the type of the destination . /// 2 // Token: 0x06000F12 RID: 3858 RVA: 0x0003F978 File Offset: 0x0003DB78 public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index"); } if (array.Rank != 1) { throw new ArgumentException("array", "Array rank must be 1"); } if (index >= array.Length && this.m_length > 0) { throw new ArgumentException("index", "index is greater than array.Length"); } if (array is bool[]) { if (array.Length - index < this.m_length) { throw new ArgumentException(); } bool[] array2 = (bool[])array; for (int i = 0; i < this.m_length; i++) { array2[index + i] = this[i]; } } else if (array is byte[]) { int num = (this.m_length + 7) / 8; if (array.Length - index < num) { throw new ArgumentException(); } byte[] array3 = (byte[])array; for (int j = 0; j < num; j++) { array3[index + j] = this.getByte(j); } } else { if (!(array is int[])) { throw new ArgumentException("array", "Unsupported type"); } Array.Copy(this.m_array, 0, array, index, (this.m_length + 31) / 32); } } /// Inverts all the bit values in the current , so that elements set to true are changed to false, and elements set to false are changed to true. /// The current instance with inverted bit values. /// 2 // Token: 0x06000F13 RID: 3859 RVA: 0x0003FAD4 File Offset: 0x0003DCD4 public BitArray Not() { int num = (this.m_length + 31) / 32; for (int i = 0; i < num; i++) { this.m_array[i] = ~this.m_array[i]; } this._version++; return this; } /// Performs the bitwise AND operation on the elements in the current against the corresponding elements in the specified . /// A containing the result of the bitwise AND operation on the elements in the current against the corresponding elements in the specified . /// The with which to perform the bitwise AND operation. /// /// is null. /// /// and the current do not have the same number of elements. /// 2 // Token: 0x06000F14 RID: 3860 RVA: 0x0003FB20 File Offset: 0x0003DD20 public BitArray And(BitArray value) { this.checkOperand(value); int num = (this.m_length + 31) / 32; for (int i = 0; i < num; i++) { this.m_array[i] &= value.m_array[i]; } this._version++; return this; } /// Performs the bitwise OR operation on the elements in the current against the corresponding elements in the specified . /// A containing the result of the bitwise OR operation on the elements in the current against the corresponding elements in the specified . /// The with which to perform the bitwise OR operation. /// /// is null. /// /// and the current do not have the same number of elements. /// 2 // Token: 0x06000F15 RID: 3861 RVA: 0x0003FB7C File Offset: 0x0003DD7C public BitArray Or(BitArray value) { this.checkOperand(value); int num = (this.m_length + 31) / 32; for (int i = 0; i < num; i++) { this.m_array[i] |= value.m_array[i]; } this._version++; return this; } /// Performs the bitwise exclusive OR operation on the elements in the current against the corresponding elements in the specified . /// A containing the result of the bitwise exclusive OR operation on the elements in the current against the corresponding elements in the specified . /// The with which to perform the bitwise exclusive OR operation. /// /// is null. /// /// and the current do not have the same number of elements. /// 2 // Token: 0x06000F16 RID: 3862 RVA: 0x0003FBD8 File Offset: 0x0003DDD8 public BitArray Xor(BitArray value) { this.checkOperand(value); int num = (this.m_length + 31) / 32; for (int i = 0; i < num; i++) { this.m_array[i] ^= value.m_array[i]; } this._version++; return this; } /// Gets the value of the bit at a specific position in the . /// The value of the bit at position . /// The zero-based index of the value to get. /// /// is less than zero.-or- is greater than or equal to the number of elements in the . /// 2 // Token: 0x06000F17 RID: 3863 RVA: 0x0003FC34 File Offset: 0x0003DE34 public bool Get(int index) { if (index < 0 || index >= this.m_length) { throw new ArgumentOutOfRangeException(); } return (this.m_array[index >> 5] & (1 << index)) != 0; } /// Sets the bit at a specific position in the to the specified value. /// The zero-based index of the bit to set. /// The Boolean value to assign to the bit. /// /// is less than zero.-or- is greater than or equal to the number of elements in the . /// 2 // Token: 0x06000F18 RID: 3864 RVA: 0x0003FC6C File Offset: 0x0003DE6C public void Set(int index, bool value) { if (index < 0 || index >= this.m_length) { throw new ArgumentOutOfRangeException(); } if (value) { this.m_array[index >> 5] |= 1 << index; } else { this.m_array[index >> 5] &= ~(1 << index); } this._version++; } /// Sets all bits in the to the specified value. /// The Boolean value to assign to all bits. /// 2 // Token: 0x06000F19 RID: 3865 RVA: 0x0003FCE8 File Offset: 0x0003DEE8 public void SetAll(bool value) { if (value) { for (int i = 0; i < this.m_array.Length; i++) { this.m_array[i] = -1; } } else { Array.Clear(this.m_array, 0, this.m_array.Length); } this._version++; } /// Returns an enumerator that iterates through the . /// An for the entire . /// 2 // Token: 0x06000F1A RID: 3866 RVA: 0x0003FD44 File Offset: 0x0003DF44 public IEnumerator GetEnumerator() { return new BitArray.BitArrayEnumerator(this); } // Token: 0x040003A9 RID: 937 private int[] m_array; // Token: 0x040003AA RID: 938 private int m_length; // Token: 0x040003AB RID: 939 private int _version; // Token: 0x02000122 RID: 290 [Serializable] private class BitArrayEnumerator : IEnumerator, ICloneable { // Token: 0x06000F1B RID: 3867 RVA: 0x0003FD4C File Offset: 0x0003DF4C public BitArrayEnumerator(BitArray ba) { this._index = -1; this._bitArray = ba; this._version = ba._version; } // Token: 0x06000F1C RID: 3868 RVA: 0x0003FD7C File Offset: 0x0003DF7C public object Clone() { return base.MemberwiseClone(); } // Token: 0x17000255 RID: 597 // (get) Token: 0x06000F1D RID: 3869 RVA: 0x0003FD84 File Offset: 0x0003DF84 public object Current { get { if (this._index == -1) { throw new InvalidOperationException("Enum not started"); } if (this._index >= this._bitArray.Count) { throw new InvalidOperationException("Enum Ended"); } return this._current; } } // Token: 0x06000F1E RID: 3870 RVA: 0x0003FDD4 File Offset: 0x0003DFD4 public bool MoveNext() { this.checkVersion(); if (this._index < this._bitArray.Count - 1) { this._current = this._bitArray[++this._index]; return true; } this._index = this._bitArray.Count; return false; } // Token: 0x06000F1F RID: 3871 RVA: 0x0003FE38 File Offset: 0x0003E038 public void Reset() { this.checkVersion(); this._index = -1; } // Token: 0x06000F20 RID: 3872 RVA: 0x0003FE48 File Offset: 0x0003E048 private void checkVersion() { if (this._version != this._bitArray._version) { throw new InvalidOperationException(); } } // Token: 0x040003AC RID: 940 private BitArray _bitArray; // Token: 0x040003AD RID: 941 private bool _current; // Token: 0x040003AE RID: 942 private int _index; // Token: 0x040003AF RID: 943 private int _version; } } }