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
51 internal static void Copy<T>(IEnumerable<T> source, T[] array, int arrayIndex, int count)
52 {
54 {
56 }
57 else
58 {
60 }
61 }
62
63 internal static void IterativeCopy<T>(IEnumerable<T> source, T[] array, int arrayIndex, int count)
64 {
65 int num = arrayIndex + count;
66 foreach (T item in source)
67 {
69 }
70 }
71
72 internal static T[] ToArray<T>(IEnumerable<T> source)
73 {
75 {
76 if (count == 0)
77 {
78 return Array.Empty<T>();
79 }
80 T[] array = new T[count];
82 return array;
83 }
86 return largeArrayBuilder.ToArray();
87 }
88}
static int MaxLength
Definition Array.cs:471
void CopyTo(Array array, int index)
Definition Array.cs:1555
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
static T[] ToArray< T >(IEnumerable< T > source, out int length)
static void Copy< T >(IEnumerable< T > source, T[] array, int arrayIndex, int count)
static void IterativeCopy< T >(IEnumerable< T > source, T[] array, int arrayIndex, int count)