Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ArrayBuilder.cs
Go to the documentation of this file.
1
namespace
System.Collections.Generic
;
2
3
internal
struct
ArrayBuilder<T>
4
{
5
private
T[]
_array
;
6
7
private
int
_count
;
8
9
public
int
Capacity
10
{
11
get
12
{
13
T[]
array
=
_array
;
14
if
(
array
==
null
)
15
{
16
return
0;
17
}
18
return
array
.Length;
19
}
20
}
21
22
public
int
Count
=>
_count
;
23
24
public
T
this
[
int
index
] =>
_array
[
index
];
25
26
public
void
Add
(T
item
)
27
{
28
if
(
_count
==
Capacity
)
29
{
30
EnsureCapacity
(
_count
+ 1);
31
}
32
UncheckedAdd
(
item
);
33
}
34
35
public
T
First
()
36
{
37
return
_array
[0];
38
}
39
40
public
T
Last
()
41
{
42
return
_array
[
_count
- 1];
43
}
44
45
public
void
UncheckedAdd
(T
item
)
46
{
47
_array
[
_count
++] =
item
;
48
}
49
50
private
void
EnsureCapacity
(
int
minimum
)
51
{
52
int
capacity
=
Capacity
;
53
int
num = ((
capacity
== 0) ? 4 : (2 *
capacity
));
54
if
((uint)num > (uint)
Array
.
MaxLength
)
55
{
56
num =
Math
.
Max
(
capacity
+ 1,
Array
.
MaxLength
);
57
}
58
num =
Math
.
Max
(num,
minimum
);
59
T[]
array
=
new
T[num];
60
if
(
_count
> 0)
61
{
62
Array
.
Copy
(
_array
,
array
,
_count
);
63
}
64
_array
=
array
;
65
}
66
}
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.ExceptionArgument.item
@ item
System.ExceptionArgument.index
@ index
System.ExceptionArgument.capacity
@ capacity
System.ExceptionArgument.array
@ array
System.Collections.Generic.ArrayBuilder._count
int _count
Definition
ArrayBuilder.cs:10
System.Collections.Generic.ArrayBuilder.Count
int Count
Definition
ArrayBuilder.cs:22
System.Collections.Generic.ArrayBuilder.EnsureCapacity
void EnsureCapacity(int minimum)
Definition
ArrayBuilder.cs:50
System.Collections.Generic.ArrayBuilder.Last
T Last()
Definition
ArrayBuilder.cs:40
System.Collections.Generic.ArrayBuilder._array
T[] _array
Definition
ArrayBuilder.cs:8
System.Collections.Generic.ArrayBuilder.Add
void Add(T item)
Definition
ArrayBuilder.cs:26
System.Collections.Generic.ArrayBuilder.First
T First()
Definition
ArrayBuilder.cs:35
System.Collections.Generic.ArrayBuilder.Capacity
int Capacity
Definition
ArrayBuilder.cs:10
System.Collections.Generic.ArrayBuilder.UncheckedAdd
void UncheckedAdd(T item)
Definition
ArrayBuilder.cs:36
source
System.Linq
System.Collections.Generic
ArrayBuilder.cs
Generated by
1.10.0