12template <
class T, u
int N>
20 static constexpr uint Capacity = N;
29 for (
const T &v : inList)
30 new (
reinterpret_cast<T *
>(&mElements[mSize++])) T(v);
36 while (mSize < inRHS.
mSize)
38 new (&mElements[mSize]) T(inRHS[mSize]);
46 if constexpr (!std::is_trivially_destructible<T>())
47 for (T *e =
reinterpret_cast<T *
>(mElements), *end = e + mSize; e < end; ++e)
54 if constexpr (!std::is_trivially_destructible<T>())
55 for (T *e =
reinterpret_cast<T *
>(mElements), *end = e + mSize; e < end; ++e)
64 new (&mElements[mSize++]) T(inElement);
72 new (&mElements[mSize++]) T(std::forward<A>(inElement)...);
79 reinterpret_cast<T &
>(mElements[--mSize]).~T();
104 if constexpr (!std::is_trivially_constructible<T>())
105 for (T *element =
reinterpret_cast<T *
>(mElements) + mSize, *element_end =
reinterpret_cast<T *
>(mElements) + inNewSize; element < element_end; ++element)
107 if constexpr (!std::is_trivially_destructible<T>())
108 for (T *element =
reinterpret_cast<T *
>(mElements) + inNewSize, *element_end =
reinterpret_cast<T *
>(mElements) + mSize; element < element_end; ++element)
118 return reinterpret_cast<const T *
>(mElements);
123 return reinterpret_cast<const T *
>(mElements + mSize);
130 return reinterpret_cast<T *
>(mElements);
135 return reinterpret_cast<T *
>(mElements + mSize);
140 return reinterpret_cast<const T *
>(mElements);
145 return reinterpret_cast<T *
>(mElements);
152 return reinterpret_cast<T &
>(mElements[inIdx]);
158 return reinterpret_cast<const T &
>(mElements[inIdx]);
165 return reinterpret_cast<T &
>(mElements[inIdx]);
171 return reinterpret_cast<const T &
>(mElements[inIdx]);
178 return reinterpret_cast<const T &
>(mElements[0]);
184 return reinterpret_cast<T &
>(mElements[0]);
191 return reinterpret_cast<const T &
>(mElements[mSize - 1]);
197 return reinterpret_cast<T &
>(mElements[mSize - 1]);
205 reinterpret_cast<T &
>(mElements[p]).~T();
207 memmove(mElements + p, mElements + p + 1, (mSize - p - 1) *
sizeof(T));
218 reinterpret_cast<T &
>(mElements[p + i]).~T();
220 memmove(mElements + p, mElements + p + n, (mSize - p - n) *
sizeof(T));
229 if (
static_cast<const void *
>(
this) !=
static_cast<const void *
>(&inRHS))
233 while (mSize < rhs_size)
235 new (&mElements[mSize]) T(inRHS[mSize]);
250 if (
static_cast<const void *
>(
this) !=
static_cast<const void *
>(&inRHS))
254 while (mSize < rhs_size)
256 new (&mElements[mSize]) T(inRHS[mSize]);
267 if (mSize != inRHS.
mSize)
270 if (!(
reinterpret_cast<const T &
>(mElements[i]) ==
reinterpret_cast<const T &
>(inRHS.
mElements[i])))
277 if (mSize != inRHS.
mSize)
280 if (
reinterpret_cast<const T &
>(mElements[i]) !=
reinterpret_cast<const T &
>(inRHS.
mElements[i]))
292 for (
const T *element =
reinterpret_cast<const T *
>(mElements), *element_end =
reinterpret_cast<const T *
>(mElements) + mSize; element < element_end; ++element)
304 static_assert(
sizeof(T) ==
sizeof(
Storage),
"Mismatch in size");
305 static_assert(
alignof(T) ==
alignof(
Storage),
"Mismatch in alignment");
313JPH_SUPPRESS_WARNING_PUSH
319 template <
class T, JPH::u
int N>
322 size_t operator () (
const JPH::StaticArray<T, N> &inRHS)
const
324 return std::size_t(inRHS.GetHash());
329JPH_SUPPRESS_WARNING_POP
std::uint8_t uint8
Definition Core.h:482
std::uint64_t uint64
Definition Core.h:485
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_CLANG_SUPPRESS_WARNING(w)
Definition Core.h:298
std::uint32_t uint32
Definition Core.h:484
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
void HashCombine(uint64 &ioSeed, const T &inValue)
Commonly used types.
Definition HashCombine.h:148
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
Simple variable length array backed by a fixed size buffer.
Definition StaticArray.h:14
StaticArray()=default
Default constructor.
void push_back(const T &inElement)
Add element to the back of the array.
Definition StaticArray.h:61
size_type capacity() const
Returns maximum amount of elements the array can hold.
Definition StaticArray.h:95
iterator end()
Definition StaticArray.h:133
T * data()
Definition StaticArray.h:143
void clear()
Destruct all elements and set length to zero.
Definition StaticArray.h:52
T value_type
Definition StaticArray.h:16
iterator begin()
Definition StaticArray.h:128
StaticArray(std::initializer_list< T > inList)
Constructor from initializer list.
Definition StaticArray.h:26
const T * const_iterator
Definition StaticArray.h:113
T * iterator
Definition StaticArray.h:126
T & front()
Definition StaticArray.h:181
void erase(const_iterator inIter)
Remove one element from the array.
Definition StaticArray.h:201
const_iterator begin() const
Iterators.
Definition StaticArray.h:116
uint size_type
Definition StaticArray.h:18
const T & back() const
Last element in the array.
Definition StaticArray.h:188
const T * data() const
Definition StaticArray.h:138
void emplace_back(A &&... inElement)
Construct element at the back of the array.
Definition StaticArray.h:69
void erase(const_iterator inBegin, const_iterator inEnd)
Remove multiple element from the array.
Definition StaticArray.h:212
T & at(size_type inIdx)
Access element.
Definition StaticArray.h:162
Storage mElements[N]
Definition StaticArray.h:308
uint64 GetHash() const
Get hash for this array.
Definition StaticArray.h:286
bool empty() const
Returns true if there are no elements in the array.
Definition StaticArray.h:83
StaticArray(const StaticArray< T, N > &inRHS)
Copy constructor.
Definition StaticArray.h:34
const T & front() const
First element in the array.
Definition StaticArray.h:175
T & back()
Definition StaticArray.h:194
const_iterator end() const
Definition StaticArray.h:121
size_type mSize
Definition StaticArray.h:307
size_type size() const
Returns amount of elements in the array.
Definition StaticArray.h:89
void pop_back()
Remove element from the back of the array.
Definition StaticArray.h:76
void resize(size_type inNewSize)
Resize array to new length.
Definition StaticArray.h:101
const T & at(size_type inIdx) const
Definition StaticArray.h:168
~StaticArray()
Destruct all elements.
Definition StaticArray.h:44
Fallback hash function that calls T::GetHash()
Definition HashCombine.h:59
Definition StaticArray.h:300