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

Class Array

Source/Engine/Core/Collections/Array.h:17–1057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15/// <typeparam name="AllocationType">The type of memory allocator.</typeparam>
16template<typename T, typename AllocationType = HeapAllocation>
17API_CLASS(InBuild) class Array
18{
19 friend Array;
20public:
21 using ItemType = T;
22 using AllocationData = typename AllocationType::template Data<T>;
23 using AllocationTag = typename AllocationType::Tag;
24
25private:
26 int32 _count;
27 int32 _capacity;
28 AllocationData _allocation;
29
30public:
31 /// <summary>
32 /// Initializes an empty <see cref="Array"/> without reserving any space.
33 /// </summary>
34 FORCE_INLINE Array()
35 : _count(0)
36 , _capacity(0)
37 {
38 }
39
40 /// <summary>
41 /// Initializes an empty <see cref="Array"/> without reserving any space.
42 /// </summary>
43 /// <param name="tag">The custom allocation tag.</param>
44 Array(AllocationTag tag)
45 : _count(0)
46 , _capacity(0)
47 , _allocation(tag)
48 {
49 }
50
51 /// <summary>
52 /// Initializes <see cref="Array"/> by reserving space.
53 /// </summary>
54 /// <param name="capacity">The number of elements that can be added without a need to allocate more memory.</param>
55 FORCE_INLINE explicit Array(const int32 capacity)
56 : _count(0)
57 , _capacity(capacity)
58 {
59 if (capacity > 0)
60 _allocation.Allocate(capacity);
61 }
62
63 /// <summary>
64 /// Initializes <see cref="Array"/> by copying elements.
65 /// </summary>
66 /// <param name="data">The initial data.</param>
67 /// <param name="length">The amount of items.</param>
68 Array(const T* data, const int32 length)
69 {
70 ASSERT(length >= 0);
71 _count = _capacity = length;
72 if (length > 0)
73 {
74 _allocation.Allocate(length);

Callers 1

ArrayMethod · 0.70

Calls 8

EnsureCapacityFunction · 0.85
ClearFunction · 0.50
sizeMethod · 0.45
GetMethod · 0.45
beginMethod · 0.45
CountMethod · 0.45
FreeMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected