blob: 6cb420954f5b9a3778718f9bc832141a7bb28332 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
template <typename TValue, int TMaxSize>
class mDynArray_c {
int currentSize;
TValue buffer[TMaxSize];
public:
mDynArray_c() { currentSize = 0; }
int count() { return currentSize; }
int max() { return TMaxSize; }
TValue& get(int index) const { return buffer[index]; }
void set(int index, TValue &newValue) { buffer[index] = newValue; }
void append(TValue &newValue) {
set(currentSize, newValue);
currentSize += 1;
}
TValue &pop() {
currentSize -= 1;
return get(currentSize - 1);
}
TValue &first() const { return get(0); }
TValue &last() const { return get(currentSize - 1); }
bool empty() const { return (currentSize == 0); }
bool full() const { return (currentSize == TMaxSize); }
};
|