Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ArrayBuilder.cs
Go to the documentation of this file.
2
3internal 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 {
31 }
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 {
63 }
64 _array = array;
65 }
66}
static int MaxLength
Definition Array.cs:471
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static byte Max(byte val1, byte val2)
Definition Math.cs:738