Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SizedArray.cs
Go to the documentation of this file.
2
3internal sealed class SizedArray : ICloneable
4{
5 internal object[] _objects;
6
7 internal object[] _negObjects;
8
9 internal object this[int index]
10 {
11 get
12 {
13 if (index < 0)
14 {
15 if (-index <= _negObjects.Length - 1)
16 {
17 return _negObjects[-index];
18 }
19 return null;
20 }
21 if (index <= _objects.Length - 1)
22 {
23 return _objects[index];
24 }
25 return null;
26 }
27 set
28 {
29 if (index < 0)
30 {
31 if (-index > _negObjects.Length - 1)
32 {
34 }
36 }
37 else
38 {
39 if (index > _objects.Length - 1)
40 {
42 }
44 }
45 }
46 }
47
48 internal SizedArray()
49 {
50 _objects = new object[16];
51 _negObjects = new object[4];
52 }
53
54 internal SizedArray(int length)
55 {
56 _objects = new object[length];
57 _negObjects = new object[length];
58 }
59
61 {
62 _objects = new object[sizedArray._objects.Length];
63 sizedArray._objects.CopyTo(_objects, 0);
64 _negObjects = new object[sizedArray._negObjects.Length];
65 sizedArray._negObjects.CopyTo(_negObjects, 0);
66 }
67
68 public object Clone()
69 {
70 return new SizedArray(this);
71 }
72
73 internal void IncreaseCapacity(int index)
74 {
75 try
76 {
77 if (index < 0)
78 {
79 int num = Math.Max(_negObjects.Length * 2, -index + 1);
80 object[] array = new object[num];
83 }
84 else
85 {
86 int num2 = Math.Max(_objects.Length * 2, index + 1);
87 object[] array2 = new object[num2];
90 }
91 }
92 catch (Exception)
93 {
95 }
96 }
97}
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
static string Serialization_CorruptedStream
Definition SR.cs:74
Definition SR.cs:7