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

◆ BinarySearch() [1/4]

override int System.Collections.ArrayList.IListWrapper.BinarySearch ( int index,
int count,
object value,
IComparer comparer )
inline

Definition at line 161 of file ArrayList.cs.

162 {
163 if (index < 0 || count < 0)
164 {
165 throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum);
166 }
167 if (Count - index < count)
168 {
169 throw new ArgumentException(SR.Argument_InvalidOffLen);
170 }
171 if (comparer == null)
172 {
173 comparer = Comparer.Default;
174 }
175 int num = index;
176 int num2 = index + count - 1;
177 while (num <= num2)
178 {
179 int num3 = (num + num2) / 2;
180 int num4 = comparer.Compare(value, _list[num3]);
181 if (num4 == 0)
182 {
183 return num3;
184 }
185 if (num4 < 0)
186 {
187 num2 = num3 - 1;
188 }
189 else
190 {
191 num = num3 + 1;
192 }
193 }
194 return ~num;
195 }

References System.Collections.ArrayList.IListWrapper._list, System.SR.Argument_InvalidOffLen, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.comparer, System.count, System.Collections.ArrayList.IListWrapper.Count, System.Collections.Comparer.Default, System.index, and System.value.