Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_Stack.c
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------------------------------------
2 // Temporal wrapper for array that works as a stack
3 // Items are stored as 'first in, last out'
4 // Items inside are always ref, so bear that in mind
5 // Might be replaced with cpp implementation with script api later on
6 class SCR_Stack<Class T>
7 {
8  protected ref array<ref T> m_aArray;
9 
10  //-----------------------------------------------------------------------------------------------------------
12  void Push(T item)
13  {
14  m_aArray.Insert(item);
15  }
16 
17  //-----------------------------------------------------------------------------------------------------------
19  T Pop()
20  {
21  int length = m_aArray.Count();
22  if (length >= 1)
23  {
24  int index = length-1;
25 
26  ref T poppedItem = m_aArray[index];
27  m_aArray.Remove(index);
28 
29  return poppedItem;
30  }
31 
32  return null;
33  }
34 
35  //-----------------------------------------------------------------------------------------------------------
37  bool IsEmpty()
38  {
39  return (m_aArray.Count() == 0);
40  }
41 
42  //-----------------------------------------------------------------------------------------------------------
44  int Count()
45  {
46  return m_aArray.Count();
47  }
48 
49  //-----------------------------------------------------------------------------------------------------------
51  void SCR_Stack()
52  {
53  m_aArray = new array<ref T>();
54  }
55 
56  //-----------------------------------------------------------------------------------------------------------
58  void ~SCR_Stack()
59  {
60  if (m_aArray)
61  {
62  m_aArray.Clear();
63  m_aArray = null;
64  }
65  }
66 };
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17