Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EnumerableHelpers.cs
Go to the documentation of this file.
2
3internal static class EnumerableHelpers
4{
5 internal static T[] ToArray<T>(IEnumerable<T> source, out int length)
6 {
8 {
9 if (count != 0)
10 {
11 T[] array = new T[count];
12 collection.CopyTo(array, 0);
13 length = count;
14 return array;
15 }
16 }
17 else
18 {
20 if (enumerator.MoveNext())
21 {
22 T[] array2 = new T[4]
23 {
24 enumerator.Current,
25 default(T),
26 default(T),
27 default(T)
28 };
29 int num = 1;
30 while (enumerator.MoveNext())
31 {
32 if (num == array2.Length)
33 {
34 int num2 = num << 1;
35 if ((uint)num2 > Array.MaxLength)
36 {
37 num2 = ((Array.MaxLength <= num) ? (num + 1) : Array.MaxLength);
38 }
39 Array.Resize(ref array2, num2);
40 }
41 array2[num++] = enumerator.Current;
42 }
43 length = num;
44 return array2;
45 }
46 }
47 length = 0;
48 return Array.Empty<T>();
49 }
50}
static int MaxLength
Definition Array.cs:471
static T[] ToArray< T >(IEnumerable< T > source, out int length)