Plasma Engine  2.0
Loading...
Searching...
No Matches
HybridArray.h
1#pragma once
2
3#include <Foundation/Containers/DynamicArray.h>
4
10template <typename T, plUInt32 Size, typename AllocatorWrapper = plDefaultAllocatorWrapper>
11class plHybridArray : public plDynamicArray<T, AllocatorWrapper>
12{
13public:
15 plHybridArray(); // [tested]
16
18 explicit plHybridArray(plAllocator* pAllocator); // [tested]
19
22
24 explicit plHybridArray(const plArrayPtr<const T>& other); // [tested]
25
27 plHybridArray(plHybridArray<T, Size, AllocatorWrapper>&& other) noexcept; // [tested]
28
30 void operator=(const plHybridArray<T, Size, AllocatorWrapper>& rhs); // [tested]
31
33 void operator=(const plArrayPtr<const T>& rhs); // [tested]
34
36 void operator=(plHybridArray<T, Size, AllocatorWrapper>&& rhs) noexcept; // [tested]
37
38protected:
40 struct alignas(PL_ALIGNMENT_OF(T))
41 {
42 plUInt8 m_StaticData[Size * sizeof(T)];
43 };
44
45 PL_ALWAYS_INLINE T* GetStaticArray() { return reinterpret_cast<T*>(m_StaticData); }
46
47 PL_ALWAYS_INLINE const T* GetStaticArray() const { return reinterpret_cast<const T*>(m_StaticData); }
48};
49
50#include <Foundation/Containers/Implementation/HybridArray_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
void operator=(const plHybridArray< T, Size, AllocatorWrapper > &rhs)
Copies the data from some other contiguous array into this one.
Definition HybridArray_inl.h:37
plHybridArray()
Creates an empty array. Does not allocate any data yet.
Definition HybridArray_inl.h:4