Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ArrayBuilder.cs
Go to the documentation of this file.
1
using
System.Reflection
;
2
3
namespace
System.Collections.Generic
;
4
5
[DefaultMember(
"Item"
)]
6
internal
struct
ArrayBuilder
<T>
7
{
8
private
T[]
_array
;
9
10
private
int
_count
;
11
12
public
int
Capacity
13
{
14
get
15
{
16
T[]
array
=
_array
;
17
if
(
array
==
null
)
18
{
19
return
0;
20
}
21
return
array
.Length;
22
}
23
}
24
25
public
void
Add
(T
item
)
26
{
27
if
(
_count
==
Capacity
)
28
{
29
EnsureCapacity
(
_count
+ 1);
30
}
31
UncheckedAdd
(
item
);
32
}
33
34
public
T[]
ToArray
()
35
{
36
if
(
_count
== 0)
37
{
38
return
Array
.Empty<T>();
39
}
40
T[]
array
=
_array
;
41
if
(
_count
<
array
.Length)
42
{
43
array
=
new
T[
_count
];
44
Array
.
Copy
(
_array
,
array
,
_count
);
45
}
46
return
array
;
47
}
48
49
public
void
UncheckedAdd
(T
item
)
50
{
51
_array
[
_count
++] =
item
;
52
}
53
54
private
void
EnsureCapacity
(
int
minimum
)
55
{
56
int
capacity
=
Capacity
;
57
int
num = ((
capacity
== 0) ? 4 : (2 *
capacity
));
58
if
((uint)num > (uint)
Array
.
MaxLength
)
59
{
60
num =
Math
.
Max
(
capacity
+ 1,
Array
.
MaxLength
);
61
}
62
num =
Math
.
Max
(num,
minimum
);
63
T[]
array
=
new
T[num];
64
if
(
_count
> 0)
65
{
66
Array
.
Copy
(
_array
,
array
,
_count
);
67
}
68
_array
=
array
;
69
}
70
}
System.Array.MaxLength
static int MaxLength
Definition
Array.cs:471
System.Array.Copy
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition
Array.cs:624
System.Array
Definition
Array.cs:16
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Math.Max
static byte Max(byte val1, byte val2)
Definition
Math.cs:738
System.Math
Definition
Math.cs:13
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Reflection
Definition
ICustomTypeProvider.cs:1
System.ExceptionArgument.item
@ item
System.ExceptionArgument.capacity
@ capacity
System.ExceptionArgument.array
@ array
System.Collections.Generic.ArrayBuilder._count
int _count
Definition
ArrayBuilder.cs:10
System.Collections.Generic.ArrayBuilder.EnsureCapacity
void EnsureCapacity(int minimum)
Definition
ArrayBuilder.cs:50
System.Collections.Generic.ArrayBuilder._array
T[] _array
Definition
ArrayBuilder.cs:8
System.Collections.Generic.ArrayBuilder.Add
void Add(T item)
Definition
ArrayBuilder.cs:25
System.Collections.Generic.ArrayBuilder.Capacity
int Capacity
Definition
ArrayBuilder.cs:10
System.Collections.Generic.ArrayBuilder.ToArray
T[] ToArray()
Definition
ArrayBuilder.cs:34
System.Collections.Generic.ArrayBuilder.UncheckedAdd
void UncheckedAdd(T item)
Definition
ArrayBuilder.cs:36
System.Collections.Generic.ArrayBuilder
Definition
ArrayBuilder.cs:7
source
System.Private.Uri
System.Collections.Generic
ArrayBuilder.cs
Generated by
1.10.0