12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #ifndef LIST_H
- #define LIST_H
- #include "common/utils/Types.h"
- template<typename T, uint L>
- class List final {
- public:
- List() : entries(0) {
- }
- List& add(const T& t) {
- if(entries >= L) {
- return *this;
- }
- data[entries++] = t;
- return *this;
- }
- List& clear() {
- entries = 0;
- return *this;
- }
- uint getLength() const {
- return entries;
- }
- uint getCapacity() const {
- return L;
- }
- T& operator[](uint index) {
- return data[index];
- }
- const T& operator[](uint index) const {
- return data[index];
- }
- const T* getData() {
- return data;
- }
- T* begin() {
- return data;
- }
- const T* begin() const {
- return data;
- }
- T* end() {
- return data + entries;
- }
- const T* end() const {
- return data + entries;
- }
- private:
- uint entries;
- T data[L];
- };
- #endif
|