| 13 | /// </remarks> |
| 14 | template<typename T, int32 ChunkSize> |
| 15 | class ChunkedArray |
| 16 | { |
| 17 | friend ChunkedArray; |
| 18 | |
| 19 | private: |
| 20 | // TODO: don't use Array but small struct and don't InlinedArray or Chunk* but Chunk (less dynamic allocations) |
| 21 | typedef Array<T> Chunk; |
| 22 | |
| 23 | int32 _count = 0; |
| 24 | Array<Chunk*, InlinedAllocation<32>> _chunks; |
| 25 | |
| 26 | public: |
| 27 | ChunkedArray() |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | ~ChunkedArray() |
| 32 | { |
| 33 | _chunks.ClearDelete(); |
| 34 | } |
| 35 | |
| 36 | public: |
| 37 | /// <summary> |
| 38 | /// Gets the amount of the elements in the collection. |
| 39 | /// </summary> |
| 40 | FORCE_INLINE int32 Count() const |
| 41 | { |
| 42 | return _count; |
| 43 | } |
| 44 | |
| 45 | /// <summary> |
| 46 | /// Gets the amount of the elements that can be hold by collection without resizing. |
| 47 | /// </summary> |
| 48 | FORCE_INLINE int32 Capacity() const |
| 49 | { |
| 50 | return _chunks.Count() * ChunkSize; |
| 51 | } |
| 52 | |
| 53 | /// <summary> |
| 54 | /// Returns true if array isn't empty. |
| 55 | /// </summary> |
| 56 | FORCE_INLINE bool HasItems() const |
| 57 | { |
| 58 | return _count != 0; |
| 59 | } |
| 60 | |
| 61 | /// <summary> |
| 62 | /// Returns true if collection is empty. |
| 63 | /// </summary> |
| 64 | FORCE_INLINE bool IsEmpty() const |
| 65 | { |
| 66 | return _count == 0; |
| 67 | } |
| 68 | |
| 69 | public: |
| 70 | // Gets element by index |
| 71 | FORCE_INLINE T& At(int32 index) const |
| 72 | { |
nothing calls this directly
no test coverage detected