| 10 | { |
| 11 | template<typename T, int size> |
| 12 | class Array |
| 13 | { |
| 14 | private: |
| 15 | T _buffer[size]; |
| 16 | int _count = 0; |
| 17 | public: |
| 18 | T* begin() const |
| 19 | { |
| 20 | return (T*)_buffer; |
| 21 | } |
| 22 | T* end() const |
| 23 | { |
| 24 | return (T*)_buffer + _count; |
| 25 | } |
| 26 | public: |
| 27 | inline int GetCapacity() const |
| 28 | { |
| 29 | return size; |
| 30 | } |
| 31 | inline int Count() const |
| 32 | { |
| 33 | return _count; |
| 34 | } |
| 35 | inline T & First() const |
| 36 | { |
| 37 | return const_cast<T&>(_buffer[0]); |
| 38 | } |
| 39 | inline T & Last() const |
| 40 | { |
| 41 | return const_cast<T&>(_buffer[_count - 1]); |
| 42 | } |
| 43 | inline void SetSize(int newSize) |
| 44 | { |
| 45 | #ifdef _DEBUG |
| 46 | if (newSize > size) |
| 47 | throw IndexOutofRangeException("size too large."); |
| 48 | #endif |
| 49 | _count = newSize; |
| 50 | } |
| 51 | inline void Add(const T & item) |
| 52 | { |
| 53 | #ifdef _DEBUG |
| 54 | if (_count == size) |
| 55 | throw IndexOutofRangeException("out of range access to static array."); |
| 56 | #endif |
| 57 | _buffer[_count++] = item; |
| 58 | } |
| 59 | inline void Add(T && item) |
| 60 | { |
| 61 | #ifdef _DEBUG |
| 62 | if (_count == size) |
| 63 | throw IndexOutofRangeException("out of range access to static array."); |
| 64 | #endif |
| 65 | _buffer[_count++] = _Move(item); |
| 66 | } |
| 67 | |
| 68 | inline T & operator [](int id) const |
| 69 | { |
nothing calls this directly
no test coverage detected