Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Length

int System.Collections.BitArray.Length
getset

Definition at line 100 of file BitArray.cs.

101 {
102 get
103 {
104 return m_length;
105 }
106 set
107 {
108 if (value < 0)
109 {
110 throw new ArgumentOutOfRangeException("value", value, System.SR.ArgumentOutOfRange_NeedNonNegNum);
111 }
112 int int32ArrayLengthFromBitLength = GetInt32ArrayLengthFromBitLength(value);
113 if (int32ArrayLengthFromBitLength > m_array.Length || int32ArrayLengthFromBitLength + 256 < m_array.Length)
114 {
115 Array.Resize(ref m_array, int32ArrayLengthFromBitLength);
116 }
117 if (value > m_length)
118 {
119 int num = m_length - 1 >> 5;
120 Div32Rem(m_length, out var remainder);
121 if (remainder > 0)
122 {
123 m_array[num] &= (1 << remainder) - 1;
124 }
125 m_array.AsSpan(num + 1, int32ArrayLengthFromBitLength - num - 1).Clear();
126 }
127 m_length = value;
128 _version++;
129 }
130 }
static int GetInt32ArrayLengthFromBitLength(int n)
Definition BitArray.cs:988
static int Div32Rem(int number, out int remainder)
Definition BitArray.cs:1003
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7

Referenced by System.Collections.BitArray.And(), System.Collections.BitArray.Not(), System.Collections.BitArray.Or(), System.Collections.BitArray.SetAll(), and System.Collections.BitArray.Xor().