Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GrowingArray.cs
Go to the documentation of this file.
2
3internal sealed class GrowingArray<T>
4{
5 private T[] _array;
6
7 private int _count;
8
9 internal T[] InternalArray => _array;
10
11 internal GrowingArray()
12 {
13 _array = new T[1024];
14 _count = 0;
15 }
16
17 internal void Add(T element)
18 {
19 if (_count >= _array.Length)
20 {
21 GrowArray(2 * _array.Length);
22 }
23 _array[_count++] = element;
24 }
25
26 private void GrowArray(int newSize)
27 {
28 T[] array = new T[newSize];
29 _array.CopyTo(array, 0);
30 _array = array;
31 }
32
33 internal void CopyFrom(T[] otherArray, int otherCount)
34 {
35 if (_count + otherCount > _array.Length)
36 {
37 GrowArray(_count + otherCount);
38 }
39 Array.Copy(otherArray, 0, _array, _count, otherCount);
40 _count += otherCount;
41 }
42}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void CopyFrom(T[] otherArray, int otherCount)