Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
sarray_ext_soa_impl.h
1#pragma once
2#include "gaia/config/config.h"
3
4#include <cstddef>
5#include <initializer_list>
6#include <new>
7#include <tuple>
8#include <type_traits>
9#include <utility>
10
11#include "gaia/cnt/impl/array_utils.h"
12#include "gaia/core/iterator.h"
13#include "gaia/core/utility.h"
14#include "gaia/mem/data_layout_policy.h"
15#include "gaia/mem/mem_utils.h"
16#include "gaia/mem/raw_data_holder.h"
17
18namespace gaia {
19 namespace cnt {
21 namespace sarr_ext_soa_detail {
22 using difference_type = int32_t;
23 using size_type = uint32_t;
24 } // namespace sarr_ext_soa_detail
26
28 template <typename T>
29 struct sarr_ext_soa_iterator {
31 using value_type = T;
32 // using pointer = T*; not supported
33 // using reference = T&; not supported
34 using difference_type = sarr_ext_soa_detail::difference_type;
36 using size_type = sarr_ext_soa_detail::size_type;
37
38 using iterator = sarr_ext_soa_iterator;
40 using iterator_category = core::random_access_iterator_tag;
41
42 private:
43 uint8_t* m_ptr;
44 size_type m_cnt;
45 size_type m_idx;
46
47 public:
48 sarr_ext_soa_iterator(uint8_t* ptr, size_type cnt, size_type idx): m_ptr(ptr), m_cnt(cnt), m_idx(idx) {}
49
50 T operator*() const {
51 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
52 }
53 T operator->() const {
54 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
55 }
56 iterator operator[](difference_type offset) const {
57 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx + offset));
58 }
59
60 iterator& operator+=(difference_type diff) {
61 m_idx = (size_type)((difference_type)m_idx + diff);
62 return *this;
63 }
64 iterator& operator-=(difference_type diff) {
65 m_idx = (size_type)((difference_type)m_idx - diff);
66 return *this;
67 }
68 iterator& operator++() {
69 ++m_idx;
70 return *this;
71 }
72 iterator operator++(int) {
73 iterator temp(*this);
74 ++*this;
75 return temp;
76 }
77 iterator& operator--() {
78 --m_idx;
79 return *this;
80 }
81 iterator operator--(int) {
82 iterator temp(*this);
83 --*this;
84 return temp;
85 }
86
87 iterator operator+(difference_type offset) const {
88 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx + offset));
89 }
90 iterator operator-(difference_type offset) const {
91 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx - offset));
92 }
93 difference_type operator-(const iterator& other) const {
94 GAIA_ASSERT(m_ptr == other.m_ptr);
95 return (difference_type)(m_idx - other.m_idx);
96 }
97
98 GAIA_NODISCARD bool operator==(const iterator& other) const {
99 GAIA_ASSERT(m_ptr == other.m_ptr);
100 return m_idx == other.m_idx;
101 }
102 GAIA_NODISCARD bool operator!=(const iterator& other) const {
103 GAIA_ASSERT(m_ptr == other.m_ptr);
104 return m_idx != other.m_idx;
105 }
106 GAIA_NODISCARD bool operator>(const iterator& other) const {
107 GAIA_ASSERT(m_ptr == other.m_ptr);
108 return m_idx > other.m_idx;
109 }
110 GAIA_NODISCARD bool operator>=(const iterator& other) const {
111 GAIA_ASSERT(m_ptr == other.m_ptr);
112 return m_idx >= other.m_idx;
113 }
114 GAIA_NODISCARD bool operator<(const iterator& other) const {
115 GAIA_ASSERT(m_ptr == other.m_ptr);
116 return m_idx < other.m_idx;
117 }
118 GAIA_NODISCARD bool operator<=(const iterator& other) const {
119 GAIA_ASSERT(m_ptr == other.m_ptr);
120 return m_idx <= other.m_idx;
121 }
122 };
123
124 template <typename T>
125 struct const_sarr_ext_soa_iterator {
126 using value_type = T;
127 // using pointer = T*; not supported
128 // using reference = T&; not supported
129 using difference_type = sarr_ext_soa_detail::difference_type;
130 using size_type = sarr_ext_soa_detail::size_type;
131
132 using iterator = const_sarr_ext_soa_iterator;
133 using iterator_category = core::random_access_iterator_tag;
134
135 private:
136 const uint8_t* m_ptr;
137 size_type m_cnt;
138 size_type m_idx;
139
140 public:
141 const_sarr_ext_soa_iterator(const uint8_t* ptr, size_type cnt, size_type idx):
142 m_ptr(ptr), m_cnt(cnt), m_idx(idx) {}
143
144 T operator*() const {
145 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
146 }
147 T operator->() const {
148 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
149 }
150 iterator operator[](difference_type offset) const {
151 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx + offset));
152 }
153
154 iterator& operator+=(difference_type diff) {
155 m_idx = (size_type)((difference_type)m_idx + diff);
156 return *this;
157 }
158 iterator& operator-=(difference_type diff) {
159 m_idx = (size_type)((difference_type)m_idx - diff);
160 return *this;
161 }
162 iterator& operator++() {
163 ++m_idx;
164 return *this;
165 }
166 iterator operator++(int) {
167 iterator temp(*this);
168 ++*this;
169 return temp;
170 }
171 iterator& operator--() {
172 --m_idx;
173 return *this;
174 }
175 iterator operator--(int) {
176 iterator temp(*this);
177 --*this;
178 return temp;
179 }
180
181 iterator operator+(difference_type offset) const {
182 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx + offset));
183 }
184 iterator operator-(difference_type offset) const {
185 return iterator(m_ptr, m_cnt, (size_type)((difference_type)m_idx - offset));
186 }
187 difference_type operator-(const iterator& other) const {
188 GAIA_ASSERT(m_ptr == other.m_ptr);
189 return (difference_type)(m_idx - other.m_idx);
190 }
191
192 GAIA_NODISCARD bool operator==(const iterator& other) const {
193 GAIA_ASSERT(m_ptr == other.m_ptr);
194 return m_idx == other.m_idx;
195 }
196 GAIA_NODISCARD bool operator!=(const iterator& other) const {
197 GAIA_ASSERT(m_ptr == other.m_ptr);
198 return m_idx != other.m_idx;
199 }
200 GAIA_NODISCARD bool operator>(const iterator& other) const {
201 GAIA_ASSERT(m_ptr == other.m_ptr);
202 return m_idx > other.m_idx;
203 }
204 GAIA_NODISCARD bool operator>=(const iterator& other) const {
205 GAIA_ASSERT(m_ptr == other.m_ptr);
206 return m_idx >= other.m_idx;
207 }
208 GAIA_NODISCARD bool operator<(const iterator& other) const {
209 GAIA_ASSERT(m_ptr == other.m_ptr);
210 return m_idx < other.m_idx;
211 }
212 GAIA_NODISCARD bool operator<=(const iterator& other) const {
213 GAIA_ASSERT(m_ptr == other.m_ptr);
214 return m_idx <= other.m_idx;
215 }
216 };
218
221 template <typename T, sarr_ext_soa_detail::size_type N>
223 static_assert(mem::is_soa_layout_v<T>, "sarr_ext_soa can be used only with soa types");
224
225 public:
226 static_assert(N > 0);
227
229 using value_type = T;
231 using reference = T&;
233 using const_reference = const T&;
235 using pointer = T*;
237 using const_pointer = const T*;
241 using difference_type = sarr_ext_soa_detail::difference_type;
243 using size_type = sarr_ext_soa_detail::size_type;
244
255
257 static constexpr size_type extent = N;
260
261 private:
262 mem::raw_data_holder<T, allocated_bytes> m_data;
263 size_type m_cnt = size_type(0);
264
265 public:
266 constexpr sarr_ext_soa() noexcept = default;
269
270 ~sarr_ext_soa() = default;
271
275 constexpr sarr_ext_soa(size_type count, const_reference value) noexcept {
276 resize(count, value);
277 }
278
281 constexpr sarr_ext_soa(size_type count) noexcept {
282 resize(count);
283 }
284
289 template <typename InputIt>
290 constexpr sarr_ext_soa(InputIt first, InputIt last) noexcept {
291 const auto count = (size_type)core::distance(first, last);
292 resize(count);
293
294 if constexpr (std::is_pointer_v<InputIt>) {
295 for (size_type i = 0; i < count; ++i)
296 operator[](i) = first[i];
297 } else if constexpr (std::is_same_v<typename InputIt::iterator_category, core::random_access_iterator_tag>) {
298 for (size_type i = 0; i < count; ++i)
299 operator[](i) = *(first[i]);
300 } else {
301 size_type i = 0;
302 for (auto it = first; it != last; ++it)
303 operator[](i++) = *it;
304 }
305 }
306
309 constexpr sarr_ext_soa(std::initializer_list<T> il): sarr_ext_soa(il.begin(), il.end()) {}
310
314
317 constexpr sarr_ext_soa(sarr_ext_soa&& other) noexcept: m_cnt(other.m_cnt) {
318 GAIA_ASSERT(core::addressof(other) != this);
319
320 mem::move_elements<T, true>(m_data, other.m_data, other.size(), 0, extent, other.extent);
321
322 other.m_cnt = size_type(0);
323 }
324
328 sarr_ext_soa& operator=(std::initializer_list<T> il) {
329 *this = sarr_ext_soa(il.begin(), il.end());
330 return *this;
331 }
332
337 GAIA_ASSERT(core::addressof(other) != this);
338
339 resize(other.size());
340 mem::copy_elements<T, true>(
341 GAIA_ACC((uint8_t*)&m_data[0]), GAIA_ACC((const uint8_t*)&other.m_data[0]), other.size(), 0, extent,
342 other.extent);
343
344 return *this;
345 }
346
350 constexpr sarr_ext_soa& operator=(sarr_ext_soa&& other) noexcept {
351 GAIA_ASSERT(core::addressof(other) != this);
352
353 resize(other.m_cnt);
354 mem::move_elements<T, true>(
355 GAIA_ACC((uint8_t*)&m_data[0]), GAIA_ACC((uint8_t*)&other.m_data[0]), other.size(), 0, extent,
356 other.extent);
357
358 other.m_cnt = size_type(0);
359
360 return *this;
361 }
362
363 GAIA_CLANG_WARNING_PUSH()
364 // Memory is aligned so we can silence this warning
365 GAIA_CLANG_WARNING_DISABLE("-Wcast-align")
366
369 GAIA_NODISCARD constexpr pointer data() noexcept {
370 return GAIA_ACC((pointer)&m_data[0]);
371 }
372
375 GAIA_NODISCARD constexpr const_pointer data() const noexcept {
376 return GAIA_ACC((const_pointer)&m_data[0]);
377 }
378
382 GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) noexcept {
383 GAIA_ASSERT(pos < size());
384 return view_policy::set({GAIA_ACC((typename view_policy::TargetCastType) & m_data[0]), extent}, pos);
385 }
386
390 GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) const noexcept {
391 GAIA_ASSERT(pos < size());
392 return view_policy::get({GAIA_ACC((typename view_policy::TargetCastType) & m_data[0]), extent}, pos);
393 }
394
395 GAIA_CLANG_WARNING_POP()
396
397
400 GAIA_ASSERT(size() < N);
401
402 operator[](m_cnt++) = arg;
403 }
404
407 constexpr void push_back(T&& arg) noexcept {
408 GAIA_ASSERT(size() < N);
409
410 operator[](m_cnt++) = GAIA_MOV(arg);
411 }
412
417 template <typename... Args>
418 constexpr decltype(auto) emplace_back(Args&&... args) noexcept {
419 GAIA_ASSERT(size() < N);
420
421 operator[](m_cnt++) = T(GAIA_FWD(args)...);
422 }
423
425 constexpr void pop_back() noexcept {
426 GAIA_ASSERT(!empty());
427
428 --m_cnt;
429 }
430
435 iterator insert(iterator pos, const T& arg) noexcept {
436 GAIA_ASSERT(size() < N);
437 GAIA_ASSERT(pos >= begin());
438 GAIA_ASSERT(pos <= end());
439
440 const auto idxSrc = (size_type)(pos - begin());
441 const auto idxDst = size();
442
443 mem::shift_elements_right<T, true>(m_data, idxDst, idxSrc, extent);
444
445 ++m_cnt;
447
448 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
449 }
450
456 GAIA_ASSERT(size() < N);
457 GAIA_ASSERT(pos >= begin());
458 GAIA_ASSERT(pos <= end());
459
460 const auto idxSrc = (size_type)(pos - begin());
461 const auto idxDst = size();
462
463 mem::shift_elements_right<T, true>(m_data, idxDst, idxSrc, extent);
464
465 ++m_cnt;
466 operator[](idxSrc) = GAIA_MOV(arg);
467
468 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
469 }
470
474 constexpr iterator erase(iterator pos) noexcept {
475 GAIA_ASSERT(empty() || (pos >= begin() && pos < end()));
476
477 if (empty())
478 return end();
479
480 const auto idxSrc = (size_type)(pos - begin());
481 const auto idxDst = size() - 1;
482
483 mem::shift_elements_left<T, true>(m_data, idxDst, idxSrc, extent);
484
485 --m_cnt;
486
487 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
488 }
489
494 iterator erase(iterator first, iterator last) noexcept {
495 GAIA_ASSERT(empty() || (first >= begin() && first < end()));
496 GAIA_ASSERT(last > first);
497 GAIA_ASSERT(last <= end());
498
499 if (empty())
500 return end();
501
502 const auto idxSrc = (size_type)(first - begin());
503 const auto idxDst = size();
504 const auto cnt = (size_type)(last - first);
505
506 mem::shift_elements_left_fast<T, true>(m_data, idxDst, idxSrc, cnt, extent);
507
508 m_cnt -= cnt;
509
510 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
511 }
512
516 GAIA_ASSERT(pos < size());
517
518 const auto idxSrc = pos;
519 const auto idxDst = size() - 1;
520
521 mem::shift_elements_left<T, true>(m_data, idxDst, idxSrc, extent);
522
523 --m_cnt;
524
525 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
526 }
527
529 constexpr void clear() noexcept {
530 resize(0);
531 }
532
535 constexpr void resize(size_type count) noexcept {
536 GAIA_ASSERT(count <= max_size());
537
538 m_cnt = count;
539 }
540
544 constexpr void resize(size_type count, const_reference value) noexcept {
545 const auto oldCount = m_cnt;
546 resize(count);
547
548 if constexpr (std::is_copy_constructible_v<value_type>) {
549 const value_type valueCopy = value;
550 for (size_type i = oldCount; i < m_cnt; ++i)
551 operator[](i) = valueCopy;
552 } else {
553 for (size_type i = oldCount; i < m_cnt; ++i)
554 operator[](i) = value;
555 }
556 }
557
563 template <typename Func>
564 auto retain(Func&& func) noexcept {
565 return detail::retain_array<true>(*this, m_cnt, func);
566 }
567
570 GAIA_NODISCARD constexpr size_type size() const noexcept {
571 return m_cnt;
572 }
573
576 GAIA_NODISCARD constexpr bool empty() const noexcept {
577 return size() == 0;
578 }
579
582 GAIA_NODISCARD constexpr size_type capacity() const noexcept {
583 return N;
584 }
585
588 GAIA_NODISCARD constexpr size_type max_size() const noexcept {
589 return N;
590 }
591
594 GAIA_NODISCARD constexpr decltype(auto) front() noexcept {
595 GAIA_ASSERT(!empty());
596 return *begin();
597 }
598
601 GAIA_NODISCARD constexpr decltype(auto) front() const noexcept {
602 GAIA_ASSERT(!empty());
603 return *begin();
604 }
605
608 GAIA_NODISCARD constexpr decltype(auto) back() noexcept {
609 GAIA_ASSERT(!empty());
610 return (operator[])(m_cnt - 1);
611 }
612
615 GAIA_NODISCARD constexpr decltype(auto) back() const noexcept {
616 GAIA_ASSERT(!empty());
617 return operator[](m_cnt - 1);
618 }
619
622 GAIA_NODISCARD constexpr auto begin() noexcept {
623 return iterator(GAIA_ACC(&m_data[0]), extent, 0);
624 }
625
628 GAIA_NODISCARD constexpr auto begin() const noexcept {
629 return const_iterator(GAIA_ACC(&m_data[0]), extent, 0);
630 }
631
634 GAIA_NODISCARD constexpr auto cbegin() const noexcept {
635 return const_iterator(GAIA_ACC(&m_data[0]), extent, 0);
636 }
637
640 GAIA_NODISCARD constexpr auto rbegin() noexcept {
641 return reverse_iterator(end());
642 }
643
646 GAIA_NODISCARD constexpr auto rbegin() const noexcept {
647 return const_reverse_iterator(end());
648 }
649
652 GAIA_NODISCARD constexpr auto crbegin() const noexcept {
654 }
655
658 GAIA_NODISCARD constexpr auto end() noexcept {
659 return iterator(GAIA_ACC(&m_data[0]), extent, size());
660 }
661
664 GAIA_NODISCARD constexpr auto end() const noexcept {
665 return const_iterator(GAIA_ACC(&m_data[0]), extent, size());
666 }
667
670 GAIA_NODISCARD constexpr auto cend() const noexcept {
671 return const_iterator(GAIA_ACC(&m_data[0]), extent, size());
672 }
673
676 GAIA_NODISCARD constexpr auto rend() noexcept {
677 return reverse_iterator(begin());
678 }
679
682 GAIA_NODISCARD constexpr auto rend() const noexcept {
684 }
685
688 GAIA_NODISCARD constexpr auto crend() const noexcept {
690 }
691
695 GAIA_NODISCARD constexpr bool operator==(const sarr_ext_soa& other) const noexcept {
696 if (m_cnt != other.m_cnt)
697 return false;
698 const size_type n = size();
699 for (size_type i = 0; i < n; ++i)
700 if (!(operator[](i) == other[i]))
701 return false;
702 return true;
703 }
704
708 GAIA_NODISCARD constexpr bool operator!=(const sarr_ext_soa& other) const noexcept {
709 return !operator==(other);
710 }
711
715 template <size_t Item>
718 std::span<uint8_t>{GAIA_ACC((uint8_t*)&m_data[0]), extent});
719 }
720
724 template <size_t Item>
727 std::span<const uint8_t>{GAIA_ACC((const uint8_t*)&m_data[0]), extent});
728 }
729 };
730
732 namespace detail {
733 template <typename T, uint32_t N, uint32_t... I>
734 constexpr sarr_ext_soa<std::remove_cv_t<T>, N> to_sarray_impl(T (&a)[N], std::index_sequence<I...> /*no_name*/) {
735 return {{a[I]...}};
736 }
737 } // namespace detail
739
745 template <typename T, uint32_t N>
746 constexpr sarr_ext_soa<std::remove_cv_t<T>, N> to_sarray(T (&a)[N]) {
747 return detail::to_sarray_impl(a, std::make_index_sequence<N>{});
748 }
749
750 } // namespace cnt
751
752} // namespace gaia
753
755namespace std {
756 template <typename T, uint32_t N>
757 struct tuple_size<gaia::cnt::sarr_ext_soa<T, N>>: std::integral_constant<uint32_t, N> {};
758
759 template <size_t I, typename T, uint32_t N>
760 struct tuple_element<I, gaia::cnt::sarr_ext_soa<T, N>> {
761 using type = T;
762 };
763} // namespace std
Array of elements of type.
Definition darray_ext_impl.h:31
GAIA_NODISCARD size_type size() const noexcept
Returns the number of elements.
Definition darray_ext_impl.h:561
pointer iterator
Mutable random-access iterator type.
Definition darray_ext_impl.h:53
GAIA_NODISCARD auto begin() noexcept
Returns an iterator to the first element.
Definition darray_ext_impl.h:613
GAIA_NODISCARD auto end() noexcept
Returns an iterator one past the last element.
Definition darray_ext_impl.h:649
GAIA_NODISCARD constexpr bool operator!=(const darr_ext &other) const noexcept
Checks whether two containers differ.
Definition darray_ext_impl.h:699
darr_ext_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition darray_ext_impl.h:50
core::random_access_iterator_tag iterator_category
Iterator category exposed by the container.
Definition darray_ext_impl.h:61
static constexpr size_type extent
Fixed capacity of the container.
Definition darray_ext_impl.h:66
darr_ext_detail::difference_type difference_type
Type used for iterator differences.
Definition darray_ext_impl.h:48
T value_type
Element type stored by the container.
Definition darray_ext_impl.h:36
GAIA_NODISCARD decltype(auto) operator[](size_type pos) noexcept
Accesses an element without bounds checking in optimized builds.
Definition darray_ext_impl.h:249
GAIA_NODISCARD bool operator==(const darr_ext &other) const noexcept
Compares two containers element by element.
Definition darray_ext_impl.h:686
Array of elements of type.
Definition sarray_ext_soa_impl.h:222
sarr_ext_soa_detail::difference_type difference_type
Type used for iterator differences.
Definition sarray_ext_soa_impl.h:241
constexpr void resize(size_type count) noexcept
Changes the number of elements.
Definition sarray_ext_soa_impl.h:535
iterator insert(iterator pos, const T &arg) noexcept
Insert the element to the position given by iterator pos.
Definition sarray_ext_soa_impl.h:435
auto view() const noexcept
Returns a read-only view of one structure-of-arrays member.
Definition sarray_ext_soa_impl.h:725
sarr_ext_soa_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition sarray_ext_soa_impl.h:243
iterator erase(iterator first, iterator last) noexcept
Removes the elements in the range [first, last)
Definition sarray_ext_soa_impl.h:494
GAIA_NODISCARD constexpr bool empty() const noexcept
Checks whether the container has no elements.
Definition sarray_ext_soa_impl.h:576
iterator erase_at(size_type pos) noexcept
Definition sarray_ext_soa_impl.h:515
sarr_ext_soa_iterator< T > iterator
Mutable random-access iterator type.
Definition sarray_ext_soa_impl.h:246
GAIA_NODISCARD constexpr auto end() noexcept
Returns an iterator one past the last element.
Definition sarray_ext_soa_impl.h:658
GAIA_NODISCARD constexpr auto begin() const noexcept
Returns an iterator to the first element.
Definition sarray_ext_soa_impl.h:628
constexpr sarr_ext_soa(std::initializer_list< T > il)
Constructs a container from an initializer list.
Definition sarray_ext_soa_impl.h:309
GAIA_NODISCARD constexpr auto crend() const noexcept
Returns the read-only reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:688
constexpr sarr_ext_soa(sarr_ext_soa &&other) noexcept
Move-constructs a container.
Definition sarray_ext_soa_impl.h:317
auto view_mut() noexcept
Returns a mutable view of one structure-of-arrays member.
Definition sarray_ext_soa_impl.h:716
GAIA_NODISCARD constexpr auto cbegin() const noexcept
Returns a read-only iterator to the first element.
Definition sarray_ext_soa_impl.h:634
GAIA_NODISCARD constexpr decltype(auto) front() const noexcept
Accesses the first element.
Definition sarray_ext_soa_impl.h:601
static constexpr size_type extent
Fixed capacity of the container.
Definition sarray_ext_soa_impl.h:257
static constexpr uint32_t allocated_bytes
Number of bytes reserved by the inline storage.
Definition sarray_ext_soa_impl.h:259
constexpr void push_back(T &&arg) noexcept
Appends an element.
Definition sarray_ext_soa_impl.h:407
const_sarr_ext_soa_iterator< T > const_iterator
Read-only random-access iterator type.
Definition sarray_ext_soa_impl.h:248
GAIA_NODISCARD constexpr decltype(auto) front() noexcept
Accesses the first element.
Definition sarray_ext_soa_impl.h:594
constexpr iterator erase(iterator pos) noexcept
Removes the element at pos.
Definition sarray_ext_soa_impl.h:474
GAIA_NODISCARD constexpr bool operator!=(const sarr_ext_soa &other) const noexcept
Checks whether two containers differ.
Definition sarray_ext_soa_impl.h:708
GAIA_NODISCARD constexpr auto rbegin() noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:640
auto retain(Func &&func) noexcept
Removes all elements that fail the predicate. The predicate may modify its element but must not chang...
Definition sarray_ext_soa_impl.h:564
constexpr void clear() noexcept
Removes all elements.
Definition sarray_ext_soa_impl.h:529
GAIA_NODISCARD constexpr decltype(auto) back() const noexcept
Accesses the last element.
Definition sarray_ext_soa_impl.h:615
core::reverse_iterator< const_iterator, difference_type > const_reverse_iterator
Read-only reverse random-access iterator type.
Definition sarray_ext_soa_impl.h:252
GAIA_NODISCARD constexpr size_type max_size() const noexcept
Returns the maximum number of elements supported by this container.
Definition sarray_ext_soa_impl.h:588
GAIA_NODISCARD constexpr decltype(auto) back() noexcept
Accesses the last element.
Definition sarray_ext_soa_impl.h:608
constexpr decltype(auto) emplace_back(Args &&... args) noexcept
Constructs and appends an element.
Definition sarray_ext_soa_impl.h:418
GAIA_NODISCARD constexpr auto rend() noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:676
GAIA_NODISCARD constexpr auto cend() const noexcept
Returns a read-only iterator one past the last element.
Definition sarray_ext_soa_impl.h:670
core::reverse_iterator< iterator, difference_type > reverse_iterator
Mutable reverse random-access iterator type.
Definition sarray_ext_soa_impl.h:250
constexpr sarr_ext_soa(InputIt first, InputIt last) noexcept
Constructs a container from an iterator range.
Definition sarray_ext_soa_impl.h:290
GAIA_NODISCARD constexpr size_type size() const noexcept
Returns the number of elements.
Definition sarray_ext_soa_impl.h:570
GAIA_NODISCARD constexpr auto crbegin() const noexcept
Returns a read-only reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:652
GAIA_NODISCARD constexpr const_pointer data() const noexcept
Returns a pointer to the element storage.
Definition sarray_ext_soa_impl.h:375
constexpr void pop_back() noexcept
Removes the last element.
Definition sarray_ext_soa_impl.h:425
GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) noexcept
Accesses an element without bounds checking in optimized builds.
Definition sarray_ext_soa_impl.h:382
GAIA_NODISCARD constexpr auto begin() noexcept
Returns an iterator to the first element.
Definition sarray_ext_soa_impl.h:622
constexpr sarr_ext_soa(size_type count, const_reference value) noexcept
Constructs a container with copies of a value.
Definition sarray_ext_soa_impl.h:275
GAIA_NODISCARD constexpr auto end() const noexcept
Returns an iterator one past the last element.
Definition sarray_ext_soa_impl.h:664
GAIA_NODISCARD constexpr auto rend() const noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:682
constexpr sarr_ext_soa & operator=(const sarr_ext_soa &other)
Copy-assigns the container.
Definition sarray_ext_soa_impl.h:336
constexpr sarr_ext_soa & operator=(sarr_ext_soa &&other) noexcept
Move-assigns the container.
Definition sarray_ext_soa_impl.h:350
constexpr void resize(size_type count, const_reference value) noexcept
Changes the size and initializes new elements from a value.
Definition sarray_ext_soa_impl.h:544
GAIA_NODISCARD constexpr auto rbegin() const noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:646
GAIA_NODISCARD constexpr pointer data() noexcept
Returns a pointer to the element storage.
Definition sarray_ext_soa_impl.h:369
constexpr sarr_ext_soa(const sarr_ext_soa &other)
Copy-constructs a container.
Definition sarray_ext_soa_impl.h:313
sarr_ext_soa & operator=(std::initializer_list< T > il)
Replaces the elements from an initializer list.
Definition sarray_ext_soa_impl.h:328
iterator insert(iterator pos, T &&arg) noexcept
Insert the element to the position given by iterator pos.
Definition sarray_ext_soa_impl.h:455
GAIA_NODISCARD constexpr size_type capacity() const noexcept
Returns the number of elements that fit without reallocation.
Definition sarray_ext_soa_impl.h:582
constexpr sarr_ext_soa(size_type count) noexcept
Constructs a container with the requested number of value-initialized elements.
Definition sarray_ext_soa_impl.h:281
constexpr void push_back(const T &arg) noexcept
Appends an element.
Definition sarray_ext_soa_impl.h:399
GAIA_NODISCARD constexpr bool operator==(const sarr_ext_soa &other) const noexcept
Compares two containers element by element.
Definition sarray_ext_soa_impl.h:695
Random-access iterator that traverses an underlying iterator in reverse. The stored iterator denotes ...
Definition iterator.h:24
View policy for accessing and storing data in the SoA way. Good for SIMD processing.
Definition data_layout_policy.h:398
GAIA_NODISCARD static constexpr ValueType get(std::span< const uint8_t > s, size_t idx) noexcept
Reconstructs a value from its SoA fields.
Definition data_layout_policy.h:526
uint8_t * TargetCastType
Pointer type used to address SoA storage.
Definition data_layout_policy.h:404
GAIA_NODISCARD static constexpr uint32_t get_min_byte_size(uintptr_t addr, size_t cnt) noexcept
Calculates the bytes required for an SoA value range.
Definition data_layout_policy.h:427
GAIA_NODISCARD static constexpr auto set(std::span< uint8_t > s, size_t idx) noexcept
Returns a mutable proxy for one complete value.
Definition data_layout_policy.h:578
Storage policy for a selected layout and item type.
Definition data_layout_policy.h:121