10template <
class T, u
int N>
18 static constexpr uint Capacity = N;
27 for (
typename std::initializer_list<T>::iterator i = inList.begin(); i != inList.end(); ++i)
28 ::new (
reinterpret_cast<T *
>(&mElements[mSize++])) T(*i);
34 while (mSize < inRHS.
mSize)
36 ::new (&mElements[mSize]) T(inRHS[mSize]);
44 if constexpr (!is_trivially_destructible<T>())
45 for (T *e =
reinterpret_cast<T *
>(mElements), *end = e + mSize; e < end; ++e)
52 if constexpr (!is_trivially_destructible<T>())
53 for (T *e =
reinterpret_cast<T *
>(mElements), *end = e + mSize; e < end; ++e)
62 ::new (&mElements[mSize++]) T(inElement);
70 ::new (&mElements[mSize++]) T(std::forward<A>(inElement)...);
77 reinterpret_cast<T &
>(mElements[--mSize]).~T();
102 if constexpr (!is_trivially_constructible<T>())
103 for (T *element =
reinterpret_cast<T *
>(mElements) + mSize, *element_end =
reinterpret_cast<T *
>(mElements) + inNewSize; element < element_end; ++element)
105 if constexpr (!is_trivially_destructible<T>())
106 for (T *element =
reinterpret_cast<T *
>(mElements) + inNewSize, *element_end =
reinterpret_cast<T *
>(mElements) + mSize; element < element_end; ++element)
116 return reinterpret_cast<const T *
>(mElements);
121 return reinterpret_cast<const T *
>(mElements + mSize);
128 return reinterpret_cast<T *
>(mElements);
133 return reinterpret_cast<T *
>(mElements + mSize);
138 return reinterpret_cast<const T *
>(mElements);
143 return reinterpret_cast<T *
>(mElements);
150 return reinterpret_cast<T &
>(mElements[inIdx]);
156 return reinterpret_cast<const T &
>(mElements[inIdx]);
163 return reinterpret_cast<const T &
>(mElements[0]);
169 return reinterpret_cast<T &
>(mElements[0]);
176 return reinterpret_cast<const T &
>(mElements[mSize - 1]);
182 return reinterpret_cast<T &
>(mElements[mSize - 1]);
190 reinterpret_cast<T &
>(mElements[p]).~T();
192 memmove(mElements + p, mElements + p + 1, (mSize - p - 1) *
sizeof(T));
203 reinterpret_cast<T &
>(mElements[p + i]).~T();
205 memmove(mElements + p, mElements + p + n, (mSize - p - n) *
sizeof(T));
214 if ((
void *)
this != (
void *)&inRHS)
218 while (mSize < rhs_size)
220 ::new (&mElements[mSize]) T(inRHS[mSize]);
235 if ((
void *)
this != (
void *)&inRHS)
239 while (mSize < rhs_size)
241 ::new (&mElements[mSize]) T(inRHS[mSize]);
252 if (mSize != inRHS.
mSize)
255 if (!(
reinterpret_cast<const T &
>(mElements[i]) ==
reinterpret_cast<const T &
>(inRHS.
mElements[i])))
262 if (mSize != inRHS.
mSize)
265 if (
reinterpret_cast<const T &
>(mElements[i]) !=
reinterpret_cast<const T &
>(inRHS.
mElements[i]))
276 static_assert(
sizeof(T) ==
sizeof(
Storage),
"Mismatch in size");
277 static_assert(
alignof(T) ==
alignof(
Storage),
"Mismatch in alignment");
285JPH_SUPPRESS_WARNING_PUSH
291 template <
class T, JPH::u
int N>
294 size_t operator () (
const JPH::StaticArray<T, N> &inRHS)
const
299 JPH::HashCombine(ret, inRHS.size());
302 for (
const T &t : inRHS)
303 JPH::HashCombine(ret, t);
310JPH_SUPPRESS_WARNING_POP
unsigned int uint
Definition Core.h:309
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_CLANG_SUPPRESS_WARNING(w)
Definition Core.h:133
uint8_t uint8
Definition Core.h:310
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
Simple variable length array backed by a fixed size buffer.
Definition StaticArray.h:12
StaticArray()=default
Default constructor.
void push_back(const T &inElement)
Add element to the back of the array.
Definition StaticArray.h:59
size_type capacity() const
Returns maximum amount of elements the array can hold.
Definition StaticArray.h:93
iterator end()
Definition StaticArray.h:131
T * data()
Definition StaticArray.h:141
void clear()
Destruct all elements and set length to zero.
Definition StaticArray.h:50
T value_type
Definition StaticArray.h:14
iterator begin()
Definition StaticArray.h:126
StaticArray(std::initializer_list< T > inList)
Constructor from initializer list.
Definition StaticArray.h:24
const T * const_iterator
Definition StaticArray.h:111
T * iterator
Definition StaticArray.h:124
T & front()
Definition StaticArray.h:166
void erase(const_iterator inIter)
Remove one element from the array.
Definition StaticArray.h:186
const_iterator begin() const
Iterators.
Definition StaticArray.h:114
uint size_type
Definition StaticArray.h:16
const T & back() const
Last element in the array.
Definition StaticArray.h:173
const T * data() const
Definition StaticArray.h:136
void emplace_back(A &&... inElement)
Construct element at the back of the array.
Definition StaticArray.h:67
void erase(const_iterator inBegin, const_iterator inEnd)
Remove multiple element from the array.
Definition StaticArray.h:197
Storage mElements[N]
Definition StaticArray.h:280
bool empty() const
Returns true if there are no elements in the array.
Definition StaticArray.h:81
StaticArray(const StaticArray< T, N > &inRHS)
Copy constructor.
Definition StaticArray.h:32
const T & front() const
First element in the array.
Definition StaticArray.h:160
T & back()
Definition StaticArray.h:179
const_iterator end() const
Definition StaticArray.h:119
size_type mSize
Definition StaticArray.h:279
size_type size() const
Returns amount of elements in the array.
Definition StaticArray.h:87
void pop_back()
Remove element from the back of the array.
Definition StaticArray.h:74
void resize(size_type inNewSize)
Resize array to new length.
Definition StaticArray.h:99
~StaticArray()
Destruct all elements.
Definition StaticArray.h:42
Definition Reference.h:207
Definition StaticArray.h:272