Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EnumerableHelpers.cs
Go to the documentation of this file.
1
namespace
System.Collections.Generic
;
2
3
internal
static
class
EnumerableHelpers
4
{
5
internal
static
T[]
ToArray<T>
(
IEnumerable<T>
source
,
out
int
length
)
6
{
7
if
(
source
is
ICollection<T>
{ Count:
var
count
}
collection
)
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
{
19
using
IEnumerator
<T>
enumerator
=
source
.
GetEnumerator
();
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
}
System.Array.MaxLength
static int MaxLength
Definition
Array.cs:471
System.Array
Definition
Array.cs:16
System.Collections.Generic.Dictionary.GetEnumerator
Enumerator GetEnumerator()
Definition
Dictionary.cs:984
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Collections.Generic.EnumerableHelpers.ToArray< T >
static T[] ToArray< T >(IEnumerable< T > source, out int length)
Definition
EnumerableHelpers.cs:5
System.Collections.Generic.EnumerableHelpers
Definition
EnumerableHelpers.cs:4
System.Collections.Generic.IEnumerator
Definition
IEnumerator.cs:4
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.ExceptionArgument.length
@ length
System.ExceptionArgument.source
@ source
System.ExceptionArgument.collection
@ collection
System.ExceptionArgument.count
@ count
System.ExceptionArgument.array
@ array
source
System.Collections
System.Collections.Generic
EnumerableHelpers.cs
Generated by
1.10.0