Push an element into the stack
| 142 | |
| 143 | /// Push an element into the stack |
| 144 | void push(const T& element) { |
| 145 | |
| 146 | // If we need to allocate more elements |
| 147 | if (mNbElements == mCapacity) { |
| 148 | |
| 149 | allocate(mCapacity > 0 ? mCapacity * 2 : 1); |
| 150 | } |
| 151 | |
| 152 | // Copy the item into the array |
| 153 | new (mArray + mNbElements) T(element); |
| 154 | |
| 155 | mNbElements++; |
| 156 | } |
| 157 | |
| 158 | /// Pop an element from the stack (remove it from the stack and return it) |
| 159 | T pop() { |
no outgoing calls