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/core/iterator.h"
12#include "gaia/core/utility.h"
13#include "gaia/mem/data_layout_policy.h"
14#include "gaia/mem/mem_utils.h"
15#include "gaia/mem/raw_data_holder.h"
16
17namespace gaia {
18 namespace cnt {
20 namespace sarr_ext_soa_detail {
21 using difference_type = uint32_t;
22 using size_type = uint32_t;
23 } // namespace sarr_ext_soa_detail
25
27 template <typename T>
28 struct sarr_ext_soa_iterator {
30 using value_type = T;
31 // using pointer = T*; not supported
32 // using reference = T&; not supported
33 using difference_type = sarr_ext_soa_detail::size_type;
35 using size_type = sarr_ext_soa_detail::size_type;
36
37 using iterator = sarr_ext_soa_iterator;
39 using iterator_category = core::random_access_iterator_tag;
40
41 private:
42 uint8_t* m_ptr;
43 uint32_t m_cnt;
44 uint32_t m_idx;
45
46 public:
47 sarr_ext_soa_iterator(uint8_t* ptr, uint32_t cnt, uint32_t idx): m_ptr(ptr), m_cnt(cnt), m_idx(idx) {}
48
49 T operator*() const {
50 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
51 }
52 T operator->() const {
53 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
54 }
55 iterator operator[](size_type offset) const {
56 return iterator(m_ptr, m_cnt, m_idx + offset);
57 }
58
59 iterator& operator+=(size_type diff) {
60 m_idx += diff;
61 return *this;
62 }
63 iterator& operator-=(size_type diff) {
64 m_idx -= diff;
65 return *this;
66 }
67 iterator& operator++() {
68 ++m_idx;
69 return *this;
70 }
71 iterator operator++(int) {
72 iterator temp(*this);
73 ++*this;
74 return temp;
75 }
76 iterator& operator--() {
77 --m_idx;
78 return *this;
79 }
80 iterator operator--(int) {
81 iterator temp(*this);
82 --*this;
83 return temp;
84 }
85
86 iterator operator+(size_type offset) const {
87 return iterator(m_ptr, m_cnt, m_idx + offset);
88 }
89 iterator operator-(size_type offset) const {
90 return iterator(m_ptr, m_cnt, m_idx + offset);
91 }
92 difference_type operator-(const iterator& other) const {
93 GAIA_ASSERT(m_ptr == other.m_ptr);
94 return (difference_type)(m_idx - other.m_idx);
95 }
96
97 GAIA_NODISCARD bool operator==(const iterator& other) const {
98 GAIA_ASSERT(m_ptr == other.m_ptr);
99 return m_idx == other.m_idx;
100 }
101 GAIA_NODISCARD bool operator!=(const iterator& other) const {
102 GAIA_ASSERT(m_ptr == other.m_ptr);
103 return m_idx != other.m_idx;
104 }
105 GAIA_NODISCARD bool operator>(const iterator& other) const {
106 GAIA_ASSERT(m_ptr == other.m_ptr);
107 return m_idx > other.m_idx;
108 }
109 GAIA_NODISCARD bool operator>=(const iterator& other) const {
110 GAIA_ASSERT(m_ptr == other.m_ptr);
111 return m_idx >= other.m_idx;
112 }
113 GAIA_NODISCARD bool operator<(const iterator& other) const {
114 GAIA_ASSERT(m_ptr == other.m_ptr);
115 return m_idx < other.m_idx;
116 }
117 GAIA_NODISCARD bool operator<=(const iterator& other) const {
118 GAIA_ASSERT(m_ptr == other.m_ptr);
119 return m_idx <= other.m_idx;
120 }
121 };
122
123 template <typename T>
124 struct const_sarr_ext_soa_iterator {
125 using value_type = T;
126 // using pointer = T*; not supported
127 // using reference = T&; not supported
128 using difference_type = sarr_ext_soa_detail::size_type;
129 using size_type = sarr_ext_soa_detail::size_type;
130
131 using iterator = const_sarr_ext_soa_iterator;
132 using iterator_category = core::random_access_iterator_tag;
133
134 private:
135 const uint8_t* m_ptr;
136 uint32_t m_cnt;
137 uint32_t m_idx;
138
139 public:
140 const_sarr_ext_soa_iterator(const uint8_t* ptr, uint32_t cnt, uint32_t idx): m_ptr(ptr), m_cnt(cnt), m_idx(idx) {}
141
142 T operator*() const {
143 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
144 }
145 T operator->() const {
146 return mem::data_view_policy<T::gaia_Data_Layout, T>::get({m_ptr, m_cnt}, m_idx);
147 }
148 iterator operator[](size_type offset) const {
149 return iterator(m_ptr, m_cnt, m_idx + offset);
150 }
151
152 iterator& operator+=(size_type diff) {
153 m_idx += diff;
154 return *this;
155 }
156 iterator& operator-=(size_type diff) {
157 m_idx -= diff;
158 return *this;
159 }
160 iterator& operator++() {
161 ++m_idx;
162 return *this;
163 }
164 iterator operator++(int) {
165 iterator temp(*this);
166 ++*this;
167 return temp;
168 }
169 iterator& operator--() {
170 --m_idx;
171 return *this;
172 }
173 iterator operator--(int) {
174 iterator temp(*this);
175 --*this;
176 return temp;
177 }
178
179 iterator operator+(size_type offset) const {
180 return iterator(m_ptr, m_cnt, m_idx + offset);
181 }
182 iterator operator-(size_type offset) const {
183 return iterator(m_ptr, m_cnt, m_idx + offset);
184 }
185 difference_type operator-(const iterator& other) const {
186 GAIA_ASSERT(m_ptr == other.m_ptr);
187 return (difference_type)(m_idx - other.m_idx);
188 }
189
190 GAIA_NODISCARD bool operator==(const iterator& other) const {
191 GAIA_ASSERT(m_ptr == other.m_ptr);
192 return m_idx == other.m_idx;
193 }
194 GAIA_NODISCARD bool operator!=(const iterator& other) const {
195 GAIA_ASSERT(m_ptr == other.m_ptr);
196 return m_idx != other.m_idx;
197 }
198 GAIA_NODISCARD bool operator>(const iterator& other) const {
199 GAIA_ASSERT(m_ptr == other.m_ptr);
200 return m_idx > other.m_idx;
201 }
202 GAIA_NODISCARD bool operator>=(const iterator& other) const {
203 GAIA_ASSERT(m_ptr == other.m_ptr);
204 return m_idx >= other.m_idx;
205 }
206 GAIA_NODISCARD bool operator<(const iterator& other) const {
207 GAIA_ASSERT(m_ptr == other.m_ptr);
208 return m_idx < other.m_idx;
209 }
210 GAIA_NODISCARD bool operator<=(const iterator& other) const {
211 GAIA_ASSERT(m_ptr == other.m_ptr);
212 return m_idx <= other.m_idx;
213 }
214 };
216
219 template <typename T, sarr_ext_soa_detail::size_type N>
221 static_assert(mem::is_soa_layout_v<T>, "sarr_ext_soa can be used only with soa types");
222
223 public:
224 static_assert(N > 0);
225
227 using value_type = T;
229 using reference = T&;
231 using const_reference = const T&;
233 using pointer = T*;
235 using const_pointer = const T*;
239 using difference_type = sarr_ext_soa_detail::difference_type;
241 using size_type = sarr_ext_soa_detail::size_type;
242
249
251 static constexpr size_type extent = N;
254
255 private:
256 mem::raw_data_holder<T, allocated_bytes> m_data;
257 size_type m_cnt = size_type(0);
258
259 public:
260 constexpr sarr_ext_soa() noexcept = default;
263
264 ~sarr_ext_soa() = default;
265
269 constexpr sarr_ext_soa(size_type count, const_reference value) noexcept {
270 resize(count, value);
271 }
272
275 constexpr sarr_ext_soa(size_type count) noexcept {
276 resize(count);
277 }
278
283 template <typename InputIt>
284 constexpr sarr_ext_soa(InputIt first, InputIt last) noexcept {
285 const auto count = (size_type)core::distance(first, last);
286 resize(count);
287
288 if constexpr (std::is_pointer_v<InputIt>) {
289 for (size_type i = 0; i < count; ++i)
290 operator[](i) = first[i];
291 } else if constexpr (std::is_same_v<typename InputIt::iterator_category, core::random_access_iterator_tag>) {
292 for (size_type i = 0; i < count; ++i)
293 operator[](i) = *(first[i]);
294 } else {
295 size_type i = 0;
296 for (auto it = first; it != last; ++it)
297 operator[](++i) = *it;
298 }
299 }
300
303 constexpr sarr_ext_soa(std::initializer_list<T> il): sarr_ext_soa(il.begin(), il.end()) {}
304
307 constexpr sarr_ext_soa(const sarr_ext_soa& other): sarr_ext_soa(other.begin(), other.end()) {}
308
311 constexpr sarr_ext_soa(sarr_ext_soa&& other) noexcept: m_cnt(other.m_cnt) {
312 GAIA_ASSERT(core::addressof(other) != this);
313
314 mem::move_elements<T, true>(m_data, other.m_data, other.size(), 0, extent, other.extent);
315
316 other.m_cnt = size_type(0);
317 }
318
322 sarr_ext_soa& operator=(std::initializer_list<T> il) {
323 *this = sarr_ext_soa(il.begin(), il.end());
324 return *this;
325 }
326
330 constexpr sarr_ext_soa& operator=(const sarr_ext_soa& other) {
331 GAIA_ASSERT(core::addressof(other) != this);
332
333 resize(other.size());
334 mem::copy_elements<T, true>(
335 GAIA_ACC((uint8_t*)&m_data[0]), GAIA_ACC((const uint8_t*)&other.m_data[0]), other.size(), 0, extent,
336 other.extent);
337
338 return *this;
339 }
340
344 constexpr sarr_ext_soa& operator=(sarr_ext_soa&& other) noexcept {
345 GAIA_ASSERT(core::addressof(other) != this);
346
347 resize(other.m_cnt);
348 mem::move_elements<T, true>(
349 GAIA_ACC((uint8_t*)&m_data[0]), GAIA_ACC((uint8_t*)&other.m_data[0]), other.size(), 0, extent,
350 other.extent);
351
352 other.m_cnt = size_type(0);
353
354 return *this;
355 }
356
357 GAIA_CLANG_WARNING_PUSH()
358 // Memory is aligned so we can silence this warning
359 GAIA_CLANG_WARNING_DISABLE("-Wcast-align")
360
363 GAIA_NODISCARD constexpr pointer data() noexcept {
364 return GAIA_ACC((pointer)&m_data[0]);
365 }
366
369 GAIA_NODISCARD constexpr const_pointer data() const noexcept {
370 return GAIA_ACC((const_pointer)&m_data[0]);
371 }
372
376 GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) noexcept {
377 GAIA_ASSERT(pos < size());
378 return view_policy::set({GAIA_ACC((typename view_policy::TargetCastType) & m_data[0]), extent}, pos);
379 }
380
384 GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) const noexcept {
385 GAIA_ASSERT(pos < size());
386 return view_policy::get({GAIA_ACC((typename view_policy::TargetCastType) & m_data[0]), extent}, pos);
387 }
388
389 GAIA_CLANG_WARNING_POP()
390
391
394 GAIA_ASSERT(size() < N);
395
396 operator[](m_cnt++) = arg;
397 }
398
401 constexpr void push_back(T&& arg) noexcept {
402 GAIA_ASSERT(size() < N);
403
404 operator[](m_cnt++) = GAIA_MOV(arg);
405 }
406
411 template <typename... Args>
412 constexpr decltype(auto) emplace_back(Args&&... args) noexcept {
413 GAIA_ASSERT(size() < N);
414
415 operator[](m_cnt++) = T(GAIA_FWD(args)...);
416 }
417
419 constexpr void pop_back() noexcept {
420 GAIA_ASSERT(!empty());
421
422 --m_cnt;
423 }
424
429 iterator insert(iterator pos, const T& arg) noexcept {
430 GAIA_ASSERT(size() < N);
431 GAIA_ASSERT(pos >= data());
432 GAIA_ASSERT(empty() || (pos < iterator(data() + size())));
433
434 const auto idxSrc = (size_type)core::distance(begin(), pos);
435 const auto idxDst = (size_type)core::distance(begin(), end());
436
437 mem::shift_elements_right<T, true>(m_data, idxDst, idxSrc, extent);
438
440
441 ++m_cnt;
442
443 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
444 }
445
451 GAIA_ASSERT(size() < N);
452 GAIA_ASSERT(pos >= data());
453 GAIA_ASSERT(empty() || (pos < iterator(data() + size())));
454
455 const auto idxSrc = (size_type)core::distance(begin(), pos);
456 const auto idxDst = (size_type)core::distance(begin(), end());
457
458 mem::shift_elements_right<T, true>(m_data, idxDst, idxSrc, extent);
459
460 operator[](idxSrc) = GAIA_MOV(arg);
461
462 ++m_cnt;
463
464 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
465 }
466
470 constexpr iterator erase(iterator pos) noexcept {
471 GAIA_ASSERT(pos >= data());
472 GAIA_ASSERT(empty() || (pos < iterator(data() + size())));
473
474 if (empty())
475 return end();
476
477 const auto idxSrc = (size_type)core::distance(begin(), pos);
478 const auto idxDst = (size_type)core::distance(begin(), end()) - 1;
479
480 mem::shift_elements_left<T, true>(m_data, idxDst, idxSrc, extent);
481
482 --m_cnt;
483
484 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
485 }
486
491 iterator erase(iterator first, iterator last) noexcept {
492 GAIA_ASSERT(first >= data())
493 GAIA_ASSERT(empty() || (first < iterator(data() + size())));
494 GAIA_ASSERT(last > first);
495 GAIA_ASSERT(last <= (data() + size()));
496
497 if (empty())
498 return end();
499
500 const auto idxSrc = (size_type)core::distance(begin(), first);
501 const auto idxDst = size();
502 const auto cnt = (size_type)(last - first);
503
504 mem::shift_elements_left_fast<T, true>(m_data, idxDst, idxSrc, cnt, extent);
505
506 m_cnt -= cnt;
507
508 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
509 }
510
514 GAIA_ASSERT(pos < size());
515
516 const auto idxSrc = pos;
517 const auto idxDst = (size_type)core::distance(begin(), end()) - 1;
518
519 mem::shift_elements_left<T, true>(m_data, idxDst, idxSrc, extent);
520
521 --m_cnt;
522
523 return iterator(GAIA_ACC(&m_data[0]), extent, idxSrc);
524 }
525
527 constexpr void clear() noexcept {
528 resize(0);
529 }
530
533 constexpr void resize(size_type count) noexcept {
534 GAIA_ASSERT(count <= max_size());
535
536 m_cnt = count;
537 }
538
542 constexpr void resize(size_type count, const_reference value) noexcept {
543 const auto oldCount = m_cnt;
544 resize(count);
545
546 if constexpr (std::is_copy_constructible_v<value_type>) {
547 const value_type valueCopy = value;
548 for (size_type i = oldCount; i < m_cnt; ++i)
549 operator[](i) = valueCopy;
550 } else {
551 for (size_type i = oldCount; i < m_cnt; ++i)
552 operator[](i) = value;
553 }
554 }
555
560 template <typename Func>
561 auto retain(Func&& func) noexcept {
562 size_type erased = 0;
563 size_type idxDst = 0;
564 size_type idxSrc = 0;
565
566 while (idxSrc < m_cnt) {
567 if (func(operator[](idxSrc))) {
568 if (idxDst < idxSrc) {
569 auto* ptr = (uint8_t*)data();
570 mem::move_element<T, true>(ptr, ptr, idxDst, idxSrc, max_size(), max_size());
571 auto* ptr2 = &data()[idxSrc];
572 core::call_dtor(ptr2);
573 }
574 ++idxDst;
575 } else {
576 auto* ptr = &data()[idxSrc];
577 core::call_dtor(ptr);
578 ++erased;
579 }
580
581 ++idxSrc;
582 }
583
584 m_cnt -= erased;
585 return idxDst;
586 }
587
590 GAIA_NODISCARD constexpr size_type size() const noexcept {
591 return m_cnt;
592 }
593
596 GAIA_NODISCARD constexpr bool empty() const noexcept {
597 return size() == 0;
598 }
599
602 GAIA_NODISCARD constexpr size_type capacity() const noexcept {
603 return N;
604 }
605
608 GAIA_NODISCARD constexpr size_type max_size() const noexcept {
609 return N;
610 }
611
614 GAIA_NODISCARD constexpr decltype(auto) front() noexcept {
615 GAIA_ASSERT(!empty());
616 return *begin();
617 }
618
621 GAIA_NODISCARD constexpr decltype(auto) front() const noexcept {
622 GAIA_ASSERT(!empty());
623 return *begin();
624 }
625
628 GAIA_NODISCARD constexpr decltype(auto) back() noexcept {
629 GAIA_ASSERT(!empty());
630 return (operator[])(m_cnt - 1);
631 }
632
635 GAIA_NODISCARD constexpr decltype(auto) back() const noexcept {
636 GAIA_ASSERT(!empty());
637 return operator[](m_cnt - 1);
638 }
639
642 GAIA_NODISCARD constexpr auto begin() noexcept {
643 return iterator(GAIA_ACC(&m_data[0]), extent, 0);
644 }
645
648 GAIA_NODISCARD constexpr auto begin() const noexcept {
649 return const_iterator(GAIA_ACC(&m_data[0]), extent, 0);
650 }
651
654 GAIA_NODISCARD constexpr auto cbegin() const noexcept {
655 return const_iterator(GAIA_ACC(&m_data[0]), extent, 0);
656 }
657
660 GAIA_NODISCARD constexpr auto rbegin() noexcept {
661 return iterator(GAIA_ACC(&m_data[0]), extent, size() - 1);
662 }
663
666 GAIA_NODISCARD constexpr auto rbegin() const noexcept {
667 return const_iterator(GAIA_ACC(&m_data[0]), extent, size() - 1);
668 }
669
672 GAIA_NODISCARD constexpr auto crbegin() const noexcept {
673 return const_iterator(GAIA_ACC(&m_data[0]), extent, size() - 1);
674 }
675
678 GAIA_NODISCARD constexpr auto end() noexcept {
679 return iterator(GAIA_ACC(&m_data[0]), extent, size());
680 }
681
684 GAIA_NODISCARD constexpr auto end() const noexcept {
685 return const_iterator(GAIA_ACC(&m_data[0]), extent, size());
686 }
687
690 GAIA_NODISCARD constexpr auto cend() const noexcept {
691 return const_iterator(GAIA_ACC(&m_data[0]), extent, size());
692 }
693
696 GAIA_NODISCARD constexpr auto rend() noexcept {
697 return iterator(GAIA_ACC(&m_data[0]), extent, -1);
698 }
699
702 GAIA_NODISCARD constexpr auto rend() const noexcept {
703 return const_iterator(GAIA_ACC(&m_data[0]), extent, -1);
704 }
705
708 GAIA_NODISCARD constexpr auto crend() const noexcept {
709 return const_iterator(GAIA_ACC(&m_data[0]), extent, -1);
710 }
711
715 GAIA_NODISCARD constexpr bool operator==(const sarr_ext_soa& other) const noexcept {
716 if (m_cnt != other.m_cnt)
717 return false;
718 const size_type n = size();
719 for (size_type i = 0; i < n; ++i)
720 if (!(operator[](i) == other[i]))
721 return false;
722 return true;
723 }
724
728 GAIA_NODISCARD constexpr bool operator!=(const sarr_ext_soa& other) const noexcept {
729 return !operator==(other);
730 }
731
735 template <size_t Item>
738 std::span<uint8_t>{GAIA_ACC((uint8_t*)&m_data[0]), extent});
739 }
740
744 template <size_t Item>
747 std::span<const uint8_t>{GAIA_ACC((const uint8_t*)&m_data[0]), extent});
748 }
749 };
750
752 namespace detail {
753 template <typename T, uint32_t N, uint32_t... I>
754 constexpr sarr_ext_soa<std::remove_cv_t<T>, N> to_sarray_impl(T (&a)[N], std::index_sequence<I...> /*no_name*/) {
755 return {{a[I]...}};
756 }
757 } // namespace detail
759
765 template <typename T, uint32_t N>
766 constexpr sarr_ext_soa<std::remove_cv_t<T>, N> to_sarray(T (&a)[N]) {
767 return detail::to_sarray_impl(a, std::make_index_sequence<N>{});
768 }
769
770 } // namespace cnt
771
772} // namespace gaia
773
775namespace std {
776 template <typename T, uint32_t N>
777 struct tuple_size<gaia::cnt::sarr_ext_soa<T, N>>: std::integral_constant<uint32_t, N> {};
778
779 template <size_t I, typename T, uint32_t N>
780 struct tuple_element<I, gaia::cnt::sarr_ext_soa<T, N>> {
781 using type = T;
782 };
783} // namespace std
Array with variable size of elements of type.
Definition darray_impl.h:27
darr_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition darray_impl.h:44
GAIA_NODISCARD decltype(auto) operator[](size_type pos) noexcept
Accesses an element without bounds checking in optimized builds.
Definition darray_impl.h:206
core::random_access_iterator_tag iterator_category
Iterator category exposed by the container.
Definition darray_impl.h:51
GAIA_NODISCARD auto begin() noexcept
Returns an iterator to the first element.
Definition darray_impl.h:556
GAIA_NODISCARD bool operator==(const darr &other) const noexcept
Compares two containers element by element.
Definition darray_impl.h:629
T value_type
Element type stored by the container.
Definition darray_impl.h:30
pointer iterator
Mutable random-access iterator type.
Definition darray_impl.h:47
darr_detail::difference_type difference_type
Type used for iterator differences.
Definition darray_impl.h:42
GAIA_NODISCARD constexpr bool operator!=(const darr &other) const noexcept
Checks whether two containers differ.
Definition darray_impl.h:642
GAIA_NODISCARD auto end() noexcept
Returns an iterator one past the last element.
Definition darray_impl.h:592
Array of elements of type.
Definition sarray_ext_soa_impl.h:220
sarr_ext_soa_detail::difference_type difference_type
Type used for iterator differences.
Definition sarray_ext_soa_impl.h:239
constexpr void resize(size_type count) noexcept
Changes the number of elements.
Definition sarray_ext_soa_impl.h:533
iterator insert(iterator pos, const T &arg) noexcept
Insert the element to the position given by iterator pos.
Definition sarray_ext_soa_impl.h:429
auto view() const noexcept
Returns a read-only view of one structure-of-arrays member.
Definition sarray_ext_soa_impl.h:745
sarr_ext_soa_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition sarray_ext_soa_impl.h:241
iterator erase(iterator first, iterator last) noexcept
Removes the elements in the range [first, last)
Definition sarray_ext_soa_impl.h:491
GAIA_NODISCARD constexpr bool empty() const noexcept
Checks whether the container has no elements.
Definition sarray_ext_soa_impl.h:596
iterator erase_at(size_type pos) noexcept
Definition sarray_ext_soa_impl.h:513
sarr_ext_soa_iterator< T > iterator
Mutable random-access iterator type.
Definition sarray_ext_soa_impl.h:244
GAIA_NODISCARD constexpr auto end() noexcept
Returns an iterator one past the last element.
Definition sarray_ext_soa_impl.h:678
GAIA_NODISCARD constexpr auto begin() const noexcept
Returns an iterator to the first element.
Definition sarray_ext_soa_impl.h:648
constexpr sarr_ext_soa(std::initializer_list< T > il)
Constructs a container from an initializer list.
Definition sarray_ext_soa_impl.h:303
GAIA_NODISCARD constexpr auto crend() const noexcept
Returns the read-only reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:708
constexpr sarr_ext_soa(sarr_ext_soa &&other) noexcept
Move-constructs a container.
Definition sarray_ext_soa_impl.h:311
auto view_mut() noexcept
Returns a mutable view of one structure-of-arrays member.
Definition sarray_ext_soa_impl.h:736
GAIA_NODISCARD constexpr auto cbegin() const noexcept
Returns a read-only iterator to the first element.
Definition sarray_ext_soa_impl.h:654
GAIA_NODISCARD constexpr decltype(auto) front() const noexcept
Accesses the first element.
Definition sarray_ext_soa_impl.h:621
static constexpr size_type extent
Fixed capacity of the container.
Definition sarray_ext_soa_impl.h:251
static constexpr uint32_t allocated_bytes
Number of bytes reserved by the inline storage.
Definition sarray_ext_soa_impl.h:253
constexpr void push_back(T &&arg) noexcept
Appends an element.
Definition sarray_ext_soa_impl.h:401
const_sarr_ext_soa_iterator< T > const_iterator
Read-only random-access iterator type.
Definition sarray_ext_soa_impl.h:246
GAIA_NODISCARD constexpr decltype(auto) front() noexcept
Accesses the first element.
Definition sarray_ext_soa_impl.h:614
constexpr iterator erase(iterator pos) noexcept
Removes the element at pos.
Definition sarray_ext_soa_impl.h:470
GAIA_NODISCARD constexpr bool operator!=(const sarr_ext_soa &other) const noexcept
Checks whether two containers differ.
Definition sarray_ext_soa_impl.h:728
GAIA_NODISCARD constexpr auto rbegin() noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:660
auto retain(Func &&func) noexcept
Removes all elements that fail the predicate.
Definition sarray_ext_soa_impl.h:561
constexpr void clear() noexcept
Removes all elements.
Definition sarray_ext_soa_impl.h:527
GAIA_NODISCARD constexpr decltype(auto) back() const noexcept
Accesses the last element.
Definition sarray_ext_soa_impl.h:635
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:608
GAIA_NODISCARD constexpr decltype(auto) back() noexcept
Accesses the last element.
Definition sarray_ext_soa_impl.h:628
constexpr decltype(auto) emplace_back(Args &&... args) noexcept
Constructs and appends an element.
Definition sarray_ext_soa_impl.h:412
GAIA_NODISCARD constexpr auto rend() noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:696
GAIA_NODISCARD constexpr auto cend() const noexcept
Returns a read-only iterator one past the last element.
Definition sarray_ext_soa_impl.h:690
constexpr sarr_ext_soa(InputIt first, InputIt last) noexcept
Constructs a container from an iterator range.
Definition sarray_ext_soa_impl.h:284
GAIA_NODISCARD constexpr size_type size() const noexcept
Returns the number of elements.
Definition sarray_ext_soa_impl.h:590
GAIA_NODISCARD constexpr auto crbegin() const noexcept
Returns a read-only reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:672
GAIA_NODISCARD constexpr const_pointer data() const noexcept
Returns a pointer to the element storage.
Definition sarray_ext_soa_impl.h:369
constexpr void pop_back() noexcept
Removes the last element.
Definition sarray_ext_soa_impl.h:419
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:376
GAIA_NODISCARD constexpr auto begin() noexcept
Returns an iterator to the first element.
Definition sarray_ext_soa_impl.h:642
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:269
GAIA_NODISCARD constexpr auto end() const noexcept
Returns an iterator one past the last element.
Definition sarray_ext_soa_impl.h:684
GAIA_NODISCARD constexpr auto rend() const noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_ext_soa_impl.h:702
constexpr sarr_ext_soa & operator=(const sarr_ext_soa &other)
Copy-assigns the container.
Definition sarray_ext_soa_impl.h:330
constexpr sarr_ext_soa & operator=(sarr_ext_soa &&other) noexcept
Move-assigns the container.
Definition sarray_ext_soa_impl.h:344
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:542
GAIA_NODISCARD constexpr auto rbegin() const noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_ext_soa_impl.h:666
GAIA_NODISCARD constexpr pointer data() noexcept
Returns a pointer to the element storage.
Definition sarray_ext_soa_impl.h:363
constexpr sarr_ext_soa(const sarr_ext_soa &other)
Copy-constructs a container.
Definition sarray_ext_soa_impl.h:307
sarr_ext_soa & operator=(std::initializer_list< T > il)
Replaces the elements from an initializer list.
Definition sarray_ext_soa_impl.h:322
iterator insert(iterator pos, T &&arg) noexcept
Insert the element to the position given by iterator pos.
Definition sarray_ext_soa_impl.h:450
GAIA_NODISCARD constexpr size_type capacity() const noexcept
Returns the number of elements that fit without reallocation.
Definition sarray_ext_soa_impl.h:602
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:275
constexpr void push_back(const T &arg) noexcept
Appends an element.
Definition sarray_ext_soa_impl.h:393
GAIA_NODISCARD constexpr bool operator==(const sarr_ext_soa &other) const noexcept
Compares two containers element by element.
Definition sarray_ext_soa_impl.h:715
View policy for accessing and storing data in the SoA way. Good for SIMD processing.
Definition data_layout_policy.h:402
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:530
uint8_t * TargetCastType
Pointer type used to address SoA storage.
Definition data_layout_policy.h:408
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:431
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:582
Storage policy for a selected layout and item type.
Definition data_layout_policy.h:123