Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ObjectReferenceStack.cs
Go to the documentation of this file.
2
4
5internal struct ObjectReferenceStack
6{
7 private const int MaximumArraySize = 16;
8
9 private const int InitialArraySize = 4;
10
11 private int _count;
12
13 private object[] _objectArray;
14
15 private bool[] _isReferenceArray;
16
18
19 internal void Push(object obj)
20 {
21 if (_objectArray == null)
22 {
23 _objectArray = new object[4];
25 return;
26 }
27 if (_count < 16)
28 {
29 if (_count == _objectArray.Length)
30 {
31 Array.Resize(ref _objectArray, _objectArray.Length * 2);
32 }
34 return;
35 }
36 if (_objectDictionary == null)
37 {
39 }
41 _count++;
42 }
43
44 internal void EnsureSetAsIsReference(object obj)
45 {
46 if (_count == 0)
47 {
48 return;
49 }
50 if (_count > 16)
51 {
54 }
55 else if (_objectArray != null && _objectArray[_count - 1] == obj)
56 {
57 if (_isReferenceArray == null)
58 {
59 _isReferenceArray = new bool[_objectArray.Length];
60 }
61 else if (_count >= _isReferenceArray.Length)
62 {
64 }
65 _isReferenceArray[_count - 1] = true;
66 }
67 }
68
69 internal void Pop(object obj)
70 {
71 if (_count > 16)
72 {
75 }
76 _count--;
77 }
78
79 internal bool Contains(object obj)
80 {
81 int num = _count;
82 if (num > 16)
83 {
85 {
86 return true;
87 }
88 num = 16;
89 }
90 for (int num2 = num - 1; num2 >= 0; num2--)
91 {
93 {
94 return true;
95 }
96 }
97 return false;
98 }
99}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)