8#ifndef RTYPE_ECS_ZIPVIEW_HPP_
9#define RTYPE_ECS_ZIPVIEW_HPP_
25 template <
class... Containers>
40 using value_type = std::tuple<typename std::remove_reference_t<Containers>::value_type&...>;
46 std::span<const Entity> entities,
76 return std::apply([e](
auto&&... args) {
77 return std::forward_as_tuple(args[e]...);
93 bool all_present = std::apply([e](
auto&&... args) {
94 return (... && args.has(e));
111 size_t min_size = std::get<0>(
_arrays).size();
113 findSmallest<0>(min_size);
145 if constexpr (I <
sizeof...(Containers)) {
146 size_t current_size = std::get<I>(
_arrays).size();
147 if (current_size < min_size) {
148 min_size = current_size;
151 findSmallest<I + 1>(min_size);
161 std::span<const Entity> result{};
164 std::apply([&](
auto&&... args) {
165 ((current++ == index ? result = args.entities() : std::span<const Entity>{}), ...);
Sparse array container for efficient component storage in ECS.
Represents an entity in the ECS (Entity-Component-System) architecture.
The actual iterator performing the intersection logic.
bool operator==(const Iterator &other) const
std::tuple< typename std::remove_reference_t< Containers >::value_type &... > value_type
tuple_arrays_t & _arrays
Tuple of references to SparseArrays.
size_t _index
Current index in the entity list.
Iterator(tuple_arrays_t &arrays, std::span< const Entity > entities, size_t index)
std::forward_iterator_tag iterator_category
std::span< const Entity > _entities
Entities of the leader SparseArray.
void skipInvalid()
Skip to the next valid entity that has all components.
std::ptrdiff_t difference_type
bool operator!=(const Iterator &other) const
A view that iterates over entities possessing all specified components.
ZipView(Containers... arrays)
Constructor for ZipView.
Iterator end()
Get iterator to the end of the zipped view.
size_t _smallest_idx
Index of the SparseArray with the fewest entities.
void findSmallest(size_t &min_size)
Find the index of the SparseArray with the smallest size.
std::span< const Entity > getEntitiesFromSmallest(size_t index)
Get the entity list from the SparseArray at the specified index.
tuple_arrays_t _arrays
Tuple of references to SparseArrays.
std::tuple< Containers... > tuple_arrays_t
Tuple type holding references to all SparseArrays.
Iterator begin()
Get iterator to the beginning of the zipped view.
File : RenderSystem.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....