MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ChunkedArray

Class ChunkedArray

Source/Engine/Core/Collections/ChunkedArray.h:15–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13/// </remarks>
14template<typename T, int32 ChunkSize>
15class ChunkedArray
16{
17 friend ChunkedArray;
18
19private:
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
26public:
27 ChunkedArray()
28 {
29 }
30
31 ~ChunkedArray()
32 {
33 _chunks.ClearDelete();
34 }
35
36public:
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
69public:
70 // Gets element by index
71 FORCE_INLINE T& At(int32 index) const
72 {

Callers

nothing calls this directly

Calls 4

AddOneMethod · 0.80
CountMethod · 0.45
SetCapacityMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected