Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SortedArray.c
Go to the documentation of this file.
1class SCR_SortedArray<Class TValue>
2{
3 protected ref array<int> m_aOrders = {};
4 protected ref array<TValue> m_aValues = {};
5
6 //------------------------------------------------------------------------------------------------
9 TValue Get(int n)
10 {
11 return m_aValues.Get(n);
12 }
13
14 //------------------------------------------------------------------------------------------------
18 void Set(int n, TValue value)
19 {
20 m_aValues.Set(n, value);
21 }
22
23 //------------------------------------------------------------------------------------------------
28 void Insert(int order, TValue value)
29 {
30 int index = Count();
31 for (int i = 0; i < index; i++)
32 {
33 if (order < m_aOrders[i])
34 {
35 index = i;
36 break;
37 }
38 }
39
40 m_aOrders.InsertAt(order, index);
41 m_aValues.InsertAt(value, index);
42 }
43
44 //------------------------------------------------------------------------------------------------
47 void Remove(int i)
48 {
49 m_aOrders.RemoveOrdered(i);
50 m_aValues.RemoveOrdered(i);
51 }
52
53 //------------------------------------------------------------------------------------------------
56 void RemoveOrders(int order)
57 {
58 for (int i = Count() - 1; i >= 0; i--)
59 {
60 if (m_aOrders[i] == order)
61 {
62 m_aOrders.RemoveOrdered(i);
63 m_aValues.RemoveOrdered(i);
64 }
65 }
66 }
67
68 //------------------------------------------------------------------------------------------------
71 void RemoveValues(TValue value)
72 {
73 for (int i = Count() - 1; i >= 0; i--)
74 {
75 if (m_aValues[i] == value)
76 {
77 m_aOrders.RemoveOrdered(i);
78 m_aValues.RemoveOrdered(i);
79 }
80 }
81 }
82
83 //------------------------------------------------------------------------------------------------
86 int GetOrder(int i)
87 {
88 return m_aOrders[i];
89 }
90
91 //------------------------------------------------------------------------------------------------
94 TValue GetValue(int i)
95 {
96 return m_aValues[i];
97 }
98
99 //------------------------------------------------------------------------------------------------
101 int Count()
102 {
103 return m_aOrders.Count();
104 }
105
106 //------------------------------------------------------------------------------------------------
108 bool IsEmpty()
109 {
110 return m_aOrders.IsEmpty();
111 }
112
113 //------------------------------------------------------------------------------------------------
115 bool Contains(TValue value)
116 {
117 return m_aValues.Contains(value);
118 }
119
120 //------------------------------------------------------------------------------------------------
124 int Find(TValue value)
125 {
126 return m_aValues.Find(value);
127 }
128
129 //------------------------------------------------------------------------------------------------
133 int CopyFrom(notnull SCR_SortedArray<TValue> from)
134 {
135 Clear();
136 int count = from.Count();
137 for (int i; i < count; i++)
138 {
139 m_aOrders.Insert(from.m_aOrders[i]);
140 m_aValues.Insert(from.m_aValues[i]);
141 }
142
143 return count;
144 }
145
146 //------------------------------------------------------------------------------------------------
148 void Clear()
149 {
150 m_aOrders.Clear();
151 m_aValues.Clear();
152 }
153
154 //------------------------------------------------------------------------------------------------
158 int ToArray(out notnull array<TValue> outArray)
159 {
160 return outArray.Copy(m_aValues);
161 }
162
163 //------------------------------------------------------------------------------------------------
165 void Debug()
166 {
167 PrintFormat("SCR_SortedArray count: %1", Count(), level: LogLevel.NORMAL);
168 for (int i, count = Count(); i < count; i++)
169 {
170 PrintFormat("[%1] => %2: %3", i, m_aOrders[i], m_aValues[i], level: LogLevel.NORMAL);
171 }
172 }
173}
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Super root of all classes in Enforce script.
Definition Types.c:35
void Set(int n, TValue value)
void Clear()
Destroys all elements of the array and sets the Count to 0.
int ToArray(out notnull array< TValue > outArray)
void Insert(int order, TValue value)
void Debug()
Print array values to log.
int CopyFrom(notnull SCR_SortedArray< TValue > from)
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
proto native void Clear()
Remove all calls from list.
TypeID handle64 Count()