EnTT  3.5.0
view.hpp
1 #ifndef ENTT_ENTITY_VIEW_HPP
2 #define ENTT_ENTITY_VIEW_HPP
3 
4 
5 #include <iterator>
6 #include <array>
7 #include <tuple>
8 #include <utility>
9 #include <algorithm>
10 #include <type_traits>
11 #include "../config/config.h"
12 #include "../core/type_traits.hpp"
13 #include "entity.hpp"
14 #include "fwd.hpp"
15 #include "pool.hpp"
16 #include "sparse_set.hpp"
17 #include "utility.hpp"
18 
19 
20 namespace entt {
21 
22 
29 template<typename...>
30 class basic_view;
31 
32 
66 template<typename Entity, typename... Exclude, typename... Component>
67 class basic_view<Entity, exclude_t<Exclude...>, Component...> {
69  friend class basic_registry<Entity>;
70 
71  template<typename Comp>
72  using pool_type = pool_t<Entity, Comp>;
73 
74  template<typename Comp>
75  using component_iterator = decltype(std::declval<pool_type<Comp>>().begin());
76 
77  using unchecked_type = std::array<const sparse_set<Entity> *, (sizeof...(Component) - 1)>;
78  using filter_type = std::array<const sparse_set<Entity> *, sizeof...(Exclude)>;
79 
80  template<typename It>
81  class view_iterator final {
82  friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;
83 
84  view_iterator(It from, It to, It curr, unchecked_type other, filter_type ignore) ENTT_NOEXCEPT
85  : first{from},
86  last{to},
87  it{curr},
88  unchecked{other},
89  filter{ignore}
90  {
91  if(it != last && !valid()) {
92  ++(*this);
93  }
94  }
95 
96  [[nodiscard]] bool valid() const {
97  return std::all_of(unchecked.cbegin(), unchecked.cend(), [entt = *it](const sparse_set<Entity> *curr) { return curr->contains(entt); })
98  && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *it](const sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
99  }
100 
101  public:
102  using difference_type = typename std::iterator_traits<It>::difference_type;
103  using value_type = typename std::iterator_traits<It>::value_type;
104  using pointer = typename std::iterator_traits<It>::pointer;
105  using reference = typename std::iterator_traits<It>::reference;
106  using iterator_category = std::bidirectional_iterator_tag;
107 
108  view_iterator() ENTT_NOEXCEPT = default;
109 
110  view_iterator & operator++() {
111  while(++it != last && !valid());
112  return *this;
113  }
114 
115  view_iterator operator++(int) {
116  view_iterator orig = *this;
117  return ++(*this), orig;
118  }
119 
120  view_iterator & operator--() ENTT_NOEXCEPT {
121  while(--it != first && !valid());
122  return *this;
123  }
124 
125  view_iterator operator--(int) ENTT_NOEXCEPT {
126  view_iterator orig = *this;
127  return operator--(), orig;
128  }
129 
130  [[nodiscard]] bool operator==(const view_iterator &other) const ENTT_NOEXCEPT {
131  return other.it == it;
132  }
133 
134  [[nodiscard]] bool operator!=(const view_iterator &other) const ENTT_NOEXCEPT {
135  return !(*this == other);
136  }
137 
138  [[nodiscard]] pointer operator->() const {
139  return &*it;
140  }
141 
142  [[nodiscard]] reference operator*() const {
143  return *operator->();
144  }
145 
146  private:
147  It first;
148  It last;
149  It it;
150  unchecked_type unchecked;
151  filter_type filter;
152  };
153 
154  class view_proxy {
155  friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;
156 
157  using proxy_view_iterator = view_iterator<typename sparse_set<Entity>::iterator>;
158 
159  class proxy_iterator {
160  friend class view_proxy;
161 
162  using ref_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Component>, std::tuple<>, std::tuple<pool_type<Component> *>>>()...));
163 
164  proxy_iterator(proxy_view_iterator from, ref_type ref) ENTT_NOEXCEPT
165  : it{from},
166  pools{ref}
167  {}
168 
169  public:
170  using difference_type = std::ptrdiff_t;
171  using value_type = decltype(std::tuple_cat(
172  std::declval<std::tuple<Entity>>(),
173  std::declval<std::conditional_t<is_eto_eligible_v<Component>, std::tuple<>, std::tuple<Component>>>()...
174  ));
175  using pointer = void;
176  using reference = decltype(std::tuple_cat(
177  std::declval<std::tuple<Entity>>(),
178  std::declval<std::conditional_t<is_eto_eligible_v<Component>, std::tuple<>, std::tuple<Component &>>>()...
179  ));
180  using iterator_category = std::input_iterator_tag;
181 
182  proxy_iterator & operator++() ENTT_NOEXCEPT {
183  return ++it, *this;
184  }
185 
186  proxy_iterator operator++(int) ENTT_NOEXCEPT {
187  proxy_iterator orig = *this;
188  return ++(*this), orig;
189  }
190 
191  [[nodiscard]] reference operator*() const ENTT_NOEXCEPT {
192  return std::apply([entt = *it](auto *... cpool) { return reference{entt, cpool->get(entt)...}; }, pools);
193  }
194 
195  [[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
196  return other.it == it;
197  }
198 
199  [[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
200  return !(*this == other);
201  }
202 
203  private:
204  proxy_view_iterator it{};
205  const ref_type pools{};
206  };
207 
208  view_proxy(proxy_view_iterator from, proxy_view_iterator to, std::tuple<pool_type<Component> *...> ref)
209  : first{from},
210  last{to},
211  pools{ref}
212  {}
213 
214  public:
215  using iterator = proxy_iterator;
216 
217  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
218  return proxy_iterator{first, std::tuple_cat([](auto *cpool) {
219  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
220  return std::make_tuple();
221  } else {
222  return std::make_tuple(cpool);
223  }
224  }(std::get<pool_type<Component> *>(pools))...)};
225  }
226 
227  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
228  return proxy_iterator{last, std::tuple_cat([](auto *cpool) {
229  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
230  return std::make_tuple();
231  } else {
232  return std::make_tuple(cpool);
233  }
234  }(std::get<pool_type<Component> *>(pools))...)};
235  }
236 
237  private:
238  proxy_view_iterator first;
239  proxy_view_iterator last;
240  const std::tuple<pool_type<Component> *...> pools;
241  };
242 
243  basic_view(pool_type<Component> &... component, unpack_as_t<const sparse_set<Entity>, Exclude> &... epool) ENTT_NOEXCEPT
244  : pools{&component...},
245  view{candidate()},
246  filter{&epool...}
247  {}
248 
249  [[nodiscard]] const sparse_set<Entity> * candidate() const ENTT_NOEXCEPT {
250  return (std::min)({ static_cast<const sparse_set<Entity> *>(std::get<pool_type<Component> *>(pools))... }, [](const auto *lhs, const auto *rhs) {
251  return lhs->size() < rhs->size();
252  });
253  }
254 
255  [[nodiscard]] unchecked_type unchecked(const sparse_set<Entity> *cpool) const {
256  std::size_t pos{};
257  unchecked_type other{};
258  ((std::get<pool_type<Component> *>(pools) == cpool ? nullptr : (other[pos] = std::get<pool_type<Component> *>(pools), other[pos++])), ...);
259  return other;
260  }
261 
262  template<typename Comp, typename Other>
263  [[nodiscard]] decltype(auto) get([[maybe_unused]] component_iterator<Comp> &it, [[maybe_unused]] pool_type<Other> *cpool, [[maybe_unused]] const Entity entt) const {
264  if constexpr(std::is_same_v<Comp, Other>) {
265  return *it;
266  } else {
267  return cpool->get(entt);
268  }
269  }
270 
271  template<typename Comp, typename Func, typename... Type>
272  void traverse(Func func, type_list<Type...>) const {
273  if constexpr(std::disjunction_v<std::is_same<Comp, Type>...>) {
274  auto it = std::get<pool_type<Comp> *>(pools)->begin();
275 
276  for(const auto entt: static_cast<const sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
277  if(((std::is_same_v<Comp, Component> || std::get<pool_type<Component> *>(pools)->contains(entt)) && ...)
278  && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
279  {
280  if constexpr(std::is_invocable_v<Func, decltype(get<Type>({}))...>) {
281  func(get<Comp, Type>(it, std::get<pool_type<Type> *>(pools), entt)...);
282  } else {
283  func(entt, get<Comp, Type>(it, std::get<pool_type<Type> *>(pools), entt)...);
284  }
285  }
286 
287  ++it;
288  }
289  } else {
290  for(const auto entt: static_cast<const sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
291  if(((std::is_same_v<Comp, Component> || std::get<pool_type<Component> *>(pools)->contains(entt)) && ...)
292  && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
293  {
294  if constexpr(std::is_invocable_v<Func, decltype(get<Type>({}))...>) {
295  func(std::get<pool_type<Type> *>(pools)->get(entt)...);
296  } else {
297  func(entt, std::get<pool_type<Type> *>(pools)->get(entt)...);
298  }
299  }
300  }
301  }
302  }
303 
304  template<typename Func, typename... Type>
305  void iterate(Func func, type_list<Type...>) const {
306  const auto last = view->data() + view->size();
307  auto first = view->data();
308 
309  while(first != last) {
310  if((std::get<pool_type<Component> *>(pools)->contains(*first) && ...)
311  && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
312  {
313  const auto base = *(first++);
314  const auto chunk = (std::min)({ (std::get<pool_type<Component> *>(pools)->size() - std::get<pool_type<Component> *>(pools)->index(base))... });
315  size_type length{};
316 
317  for(++length;
318  length < chunk
319  && ((*(std::get<pool_type<Component> *>(pools)->data() + std::get<pool_type<Component> *>(pools)->index(base) + length) == *first) && ...)
320  && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
321  ++length, ++first);
322 
323  func(view->data() + view->index(base), (std::get<pool_type<Type> *>(pools)->raw() + std::get<pool_type<Type> *>(pools)->index(base))..., length);
324  } else {
325  ++first;
326  }
327  }
328  }
329 
330 public:
332  using entity_type = Entity;
334  using size_type = std::size_t;
336  using iterator = view_iterator<typename sparse_set<entity_type>::iterator>;
338  using reverse_iterator = view_iterator<typename sparse_set<entity_type>::reverse_iterator>;
339 
348  template<typename Comp>
349  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
350  return std::get<pool_type<Comp> *>(pools)->size();
351  }
352 
357  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
358  return (std::min)({ std::get<pool_type<Component> *>(pools)->size()... });
359  }
360 
371  template<typename... Comp>
372  [[nodiscard]] bool empty() const ENTT_NOEXCEPT {
373  if constexpr(sizeof...(Comp) == 0) {
374  return (std::get<pool_type<Component> *>(pools)->empty() || ...);
375  } else {
376  return (std::get<pool_type<Comp> *>(pools)->empty() && ...);
377  }
378  }
379 
394  template<typename Comp>
395  [[nodiscard]] Comp * raw() const ENTT_NOEXCEPT {
396  return std::get<pool_type<Comp> *>(pools)->raw();
397  }
398 
413  template<typename Comp>
414  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
415  return std::get<pool_type<Comp> *>(pools)->data();
416  }
417 
430  [[nodiscard]] iterator begin() const {
431  return iterator{view->begin(), view->end(), view->begin(), unchecked(view), filter};
432  }
433 
447  [[nodiscard]] iterator end() const {
448  return iterator{view->begin(), view->end(), view->end(), unchecked(view), filter};
449  }
450 
463  [[nodiscard]] reverse_iterator rbegin() const {
464  return reverse_iterator{view->rbegin(), view->rend(), view->rbegin(), unchecked(view), filter};
465  }
466 
482  [[nodiscard]] reverse_iterator rend() const {
483  return reverse_iterator{view->rbegin(), view->rend(), view->rend(), unchecked(view), filter};
484  }
485 
491  [[nodiscard]] entity_type front() const {
492  const auto it = begin();
493  return it != end() ? *it : null;
494  }
495 
501  [[nodiscard]] entity_type back() const {
502  const auto it = rbegin();
503  return it != rend() ? *it : null;
504  }
505 
512  [[nodiscard]] iterator find(const entity_type entt) const {
513  iterator it{view->begin(), view->end(), view->find(entt), unchecked(view), filter};
514  return (it != end() && *it == entt) ? it : end();
515  }
516 
522  [[nodiscard]] bool contains(const entity_type entt) const {
523  return (std::get<pool_type<Component> *>(pools)->contains(entt) && ...)
524  && (sizeof...(Exclude) == 0 || std::none_of(filter.begin(), filter.end(), [entt](const auto *cpool) { return cpool->contains(entt); }));
525  }
526 
544  template<typename... Comp>
545  [[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) const {
546  ENTT_ASSERT(contains(entt));
547 
548  if constexpr(sizeof...(Comp) == 0) {
549  static_assert(sizeof...(Component) == 1, "Invalid component type");
550  return (std::get<pool_type<Component> *>(pools)->get(entt), ...);
551  } else if constexpr(sizeof...(Comp) == 1) {
552  return (std::get<pool_type<Comp> *>(pools)->get(entt), ...);
553  } else {
554  return std::tuple<decltype(get<Comp>({}))...>{get<Comp>(entt)...};
555  }
556  }
557 
580  template<typename Func>
581  void each(Func func) const {
582  view = candidate();
583  ((std::get<pool_type<Component> *>(pools) == view ? each<Component>(std::move(func)) : void()), ...);
584  }
585 
602  template<typename Comp, typename Func>
603  void each(Func func) const {
605  traverse<Comp>(std::move(func), non_empty_type{});
606  }
607 
621  [[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
622  view = candidate();
623  return view_proxy{begin(), end(), pools};
624  }
625 
640  template<typename Comp>
641  [[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
642  const sparse_set<entity_type> *cpool = std::get<pool_type<Comp> *>(pools);
643  iterator first{cpool->begin(), cpool->end(), cpool->begin(), unchecked(cpool), filter};
644  iterator last{cpool->begin(), cpool->end(), cpool->end(), unchecked(cpool), filter};
645  return view_proxy{std::move(first), std::move(last), pools};
646  }
647 
680  template<typename Func>
681  void chunked(Func func) const {
683  view = candidate();
684  iterate(std::move(func), non_empty_type{});
685  }
686 
687 private:
688  const std::tuple<pool_type<Component> *...> pools;
689  mutable const sparse_set<entity_type>* view;
690  filter_type filter;
691 };
692 
693 
725 template<typename Entity, typename Component>
726 class basic_view<Entity, exclude_t<>, Component> {
728  friend class basic_registry<Entity>;
729 
730  using pool_type = pool_t<Entity, Component>;
731 
732  class view_proxy {
733  friend class basic_view<Entity, exclude_t<>, Component>;
734 
735  class proxy_iterator {
736  friend class view_proxy;
737 
738  using it_type = std::conditional_t<
739  is_eto_eligible_v<Component>,
740  std::tuple<typename sparse_set<Entity>::iterator>,
741  std::tuple<typename sparse_set<Entity>::iterator, decltype(std::declval<pool_type>().begin())>
742  >;
743 
744  proxy_iterator(it_type from) ENTT_NOEXCEPT
745  : it{from}
746  {}
747 
748  public:
749  using difference_type = std::ptrdiff_t;
750  using value_type = std::conditional_t<is_eto_eligible_v<Component>, std::tuple<Entity>, std::tuple<Entity, Component>>;
751  using pointer = void;
752  using reference = std::conditional_t<is_eto_eligible_v<Component>, std::tuple<Entity>, std::tuple<Entity, Component &>>;
753  using iterator_category = std::input_iterator_tag;
754 
755  proxy_iterator & operator++() ENTT_NOEXCEPT {
756  return std::apply([](auto &&... curr) { (++curr, ...); }, it), *this;
757  }
758 
759  proxy_iterator operator++(int) ENTT_NOEXCEPT {
760  proxy_iterator orig = *this;
761  return ++(*this), orig;
762  }
763 
764  [[nodiscard]] reference operator*() const ENTT_NOEXCEPT {
765  return std::apply([](auto &&... curr) { return reference{*curr...}; }, it);
766  }
767 
768  [[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
769  return std::get<0>(other.it) == std::get<0>(it);
770  }
771 
772  [[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
773  return !(*this == other);
774  }
775 
776  private:
777  it_type it{};
778  };
779 
780  view_proxy(pool_type &ref)
781  : pool{&ref}
782  {}
783 
784  public:
785  using iterator = proxy_iterator;
786 
787  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
788  if constexpr(is_eto_eligible_v<Component>) {
789  return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::begin())};
790  } else {
791  return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::begin(), pool->begin())};
792  }
793  }
794 
795  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
796  if constexpr(is_eto_eligible_v<Component>) {
797  return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::end())};
798  } else {
799  return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::end(), pool->end())};
800  }
801  }
802 
803  private:
804  pool_type *pool;
805  };
806 
807  basic_view(pool_type &ref) ENTT_NOEXCEPT
808  : pool{&ref}
809  {}
810 
811 public:
813  using raw_type = Component;
815  using entity_type = Entity;
817  using size_type = std::size_t;
822 
827  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
828  return pool->size();
829  }
830 
835  [[nodiscard]] bool empty() const ENTT_NOEXCEPT {
836  return pool->empty();
837  }
838 
851  [[nodiscard]] raw_type * raw() const ENTT_NOEXCEPT {
852  return pool->raw();
853  }
854 
867  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
868  return pool->data();
869  }
870 
883  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
884  return pool->sparse_set<Entity>::begin();
885  }
886 
900  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
901  return pool->sparse_set<Entity>::end();
902  }
903 
916  [[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
917  return pool->sparse_set<Entity>::rbegin();
918  }
919 
935  [[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
936  return pool->sparse_set<Entity>::rend();
937  }
938 
944  [[nodiscard]] entity_type front() const {
945  const auto it = begin();
946  return it != end() ? *it : null;
947  }
948 
954  [[nodiscard]] entity_type back() const {
955  const auto it = rbegin();
956  return it != rend() ? *it : null;
957  }
958 
965  [[nodiscard]] iterator find(const entity_type entt) const {
966  const auto it = pool->find(entt);
967  return it != end() && *it == entt ? it : end();
968  }
969 
975  [[nodiscard]] entity_type operator[](const size_type pos) const {
976  return begin()[pos];
977  }
978 
984  [[nodiscard]] bool contains(const entity_type entt) const {
985  return pool->contains(entt);
986  }
987 
1003  template<typename Comp = Component>
1004  [[nodiscard]] decltype(auto) get(const entity_type entt) const {
1005  static_assert(std::is_same_v<Comp, Component>, "Invalid component type");
1006  ENTT_ASSERT(contains(entt));
1007  return pool->get(entt);
1008  }
1009 
1032  template<typename Func>
1033  void each(Func func) const {
1034  if constexpr(is_eto_eligible_v<Component>) {
1035  if constexpr(std::is_invocable_v<Func>) {
1036  for(auto pos = pool->size(); pos; --pos) {
1037  func();
1038  }
1039  } else {
1040  for(const auto entt: *this) {
1041  func(entt);
1042  }
1043  }
1044  } else {
1045  if constexpr(std::is_invocable_v<Func, decltype(get({}))>) {
1046  for(auto &&component: *pool) {
1047  func(component);
1048  }
1049  } else {
1050  auto raw = pool->begin();
1051 
1052  for(const auto entt: *this) {
1053  func(entt, *(raw++));
1054  }
1055  }
1056  }
1057  }
1058 
1072  [[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
1073  return view_proxy{*pool};
1074  }
1075 
1076 private:
1077  pool_type *pool;
1078 };
1079 
1080 
1081 }
1082 
1083 
1084 #endif
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::rbegin
reverse_iterator rbegin() const
Returns an iterator to the first entity of the reversed view.
Definition: view.hpp:463
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::empty
bool empty() const noexcept
Checks whether a view or some pools are empty.
Definition: view.hpp:372
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::front
entity_type front() const
Returns the first entity of the view, if any.
Definition: view.hpp:491
entt::type_list
A class to use to push around lists of types, nothing more.
Definition: type_traits.hpp:77
entt::basic_view< Entity, exclude_t<>, Component >::rend
reverse_iterator rend() const noexcept
Returns an iterator that is past the last entity of the reversed view.
Definition: view.hpp:935
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::iterator
view_iterator< typename sparse_set< entity_type >::iterator > iterator
Bidirectional iterator type.
Definition: view.hpp:336
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::back
entity_type back() const
Returns the last entity of the view, if any.
Definition: view.hpp:501
entt::sparse_set
Basic sparse set implementation.
Definition: sparse_set.hpp:43
entt::get
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: utility.hpp:40
entt::basic_view< Entity, exclude_t<>, Component >::front
entity_type front() const
Returns the first entity of the view, if any.
Definition: view.hpp:944
entt::basic_view< Entity, exclude_t<>, Component >::raw
raw_type * raw() const noexcept
Direct access to the list of components.
Definition: view.hpp:851
entt::type_list_cat_t
typename type_list_cat< List... >::type type_list_cat_t
Helper type.
Definition: type_traits.hpp:145
entt::sparse_set::begin
iterator begin() const noexcept
Returns an iterator to the beginning.
Definition: sparse_set.hpp:291
entt::exclude_t
Alias for exclusion lists.
Definition: utility.hpp:16
entt::sparse_set::reverse_iterator
const entity_type * reverse_iterator
Reverse iterator type.
Definition: sparse_set.hpp:184
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::size
size_type size() const noexcept
Estimates the number of entities iterated by the view.
Definition: view.hpp:357
entt::view
basic_view< entity, Types... > view
Alias declaration for the most common use case.
Definition: fwd.hpp:92
entt::sparse_set::end
iterator end() const noexcept
Returns an iterator to the end.
Definition: sparse_set.hpp:306
entt::sparse_set::iterator
sparse_set_iterator iterator
Random access iterator type.
Definition: sparse_set.hpp:182
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::find
iterator find(const entity_type entt) const
Finds an entity.
Definition: view.hpp:512
entt::basic_view< Entity, exclude_t<>, Component >::reverse_iterator
typename sparse_set< Entity >::reverse_iterator reverse_iterator
Reversed iterator type.
Definition: view.hpp:821
entt::pool
Applies component-to-pool conversion and defines the resulting type as the member typedef type.
Definition: pool.hpp:27
entt::basic_view< Entity, exclude_t<>, Component >::raw_type
Component raw_type
Type of component iterated by the view.
Definition: view.hpp:813
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::size
size_type size() const noexcept
Returns the number of existing components of the given type.
Definition: view.hpp:349
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::contains
bool contains(const entity_type entt) const
Checks if a view contains an entity.
Definition: view.hpp:522
entt::basic_view< Entity, exclude_t<>, Component >::find
iterator find(const entity_type entt) const
Finds an entity.
Definition: view.hpp:965
entt::basic_view< Entity, exclude_t<>, Component >::iterator
typename sparse_set< Entity >::iterator iterator
Random access iterator type.
Definition: view.hpp:819
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::end
iterator end() const
Returns an iterator that is past the last entity of the view.
Definition: view.hpp:447
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::chunked
void chunked(Func func) const
Chunked iteration for entities and components.
Definition: view.hpp:681
entt::basic_view< Entity, exclude_t<>, Component >::operator[]
entity_type operator[](const size_type pos) const
Returns the identifier that occupies the given position.
Definition: view.hpp:975
entt::basic_view< Entity, exclude_t<>, Component >::end
iterator end() const noexcept
Returns an iterator that is past the last entity of the view.
Definition: view.hpp:900
entt
EnTT default namespace.
Definition: algorithm.hpp:13
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::each
void each(Func func) const
Iterates entities and components and applies the given function object to them.
Definition: view.hpp:581
entt::basic_view< Entity, exclude_t<>, Component >::empty
bool empty() const noexcept
Checks whether a view is empty.
Definition: view.hpp:835
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::each
void each(Func func) const
Iterates entities and components and applies the given function object to them.
Definition: view.hpp:603
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::raw
Comp * raw() const noexcept
Direct access to the list of components of a given pool.
Definition: view.hpp:395
entt::unpack_as_t
Type unpack_as_t
Using declaration to be used to repeat the same type a number of times equal to the size of a given p...
Definition: type_traits.hpp:21
entt::basic_view< Entity, exclude_t<>, Component >::size_type
std::size_t size_type
Unsigned integer type.
Definition: view.hpp:817
entt::is_eto_eligible_v
constexpr auto is_eto_eligible_v
Helper variable template.
Definition: type_traits.hpp:225
entt::basic_view< Entity, exclude_t<>, Component >::each
void each(Func func) const
Iterates entities and components and applies the given function object to them.
Definition: view.hpp:1033
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::reverse_iterator
view_iterator< typename sparse_set< entity_type >::reverse_iterator > reverse_iterator
Reverse iterator type.
Definition: view.hpp:338
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::proxy
auto proxy() const noexcept
Returns an iterable object to use to visit the view.
Definition: view.hpp:621
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::rend
reverse_iterator rend() const
Returns an iterator that is past the last entity of the reversed view.
Definition: view.hpp:482
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::begin
iterator begin() const
Returns an iterator to the first entity of the view.
Definition: view.hpp:430
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::size_type
std::size_t size_type
Unsigned integer type.
Definition: view.hpp:334
entt::basic_view< Entity, exclude_t<>, Component >::begin
iterator begin() const noexcept
Returns an iterator to the first entity of the view.
Definition: view.hpp:883
entt::basic_view< Entity, exclude_t<>, Component >::entity_type
Entity entity_type
Underlying entity identifier.
Definition: view.hpp:815
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::proxy
auto proxy() const noexcept
Returns an iterable object to use to visit the view.
Definition: view.hpp:641
entt::basic_view< Entity, exclude_t<>, Component >::contains
bool contains(const entity_type entt) const
Checks if a view contains an entity.
Definition: view.hpp:984
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::data
const entity_type * data() const noexcept
Direct access to the list of entities of a given pool.
Definition: view.hpp:414
entt::basic_view< Entity, exclude_t<>, Component >::back
entity_type back() const
Returns the last entity of the view, if any.
Definition: view.hpp:954
entt::basic_registry
Fast and reliable entity-component system.
Definition: fwd.hpp:12
entt::basic_view< Entity, exclude_t<>, Component >::rbegin
reverse_iterator rbegin() const noexcept
Returns an iterator to the first entity of the reversed view.
Definition: view.hpp:916
entt::operator!=
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
Definition: hashed_string.hpp:227
entt::operator==
constexpr bool operator==(const Entity entity, null_t other) noexcept
Compares a null object and an entity identifier of any type.
Definition: entity.hpp:184
entt::basic_view
View.
Definition: fwd.hpp:16
entt::basic_view< Entity, exclude_t<>, Component >::proxy
auto proxy() const noexcept
Returns an iterable object to use to visit the view.
Definition: view.hpp:1072
entt::pool_t
typename pool< Entity, Type >::type pool_t
Alias declaration to use to make component-to-pool conversions.
Definition: pool.hpp:47
entt::basic_view< Entity, exclude_t< Exclude... >, Component... >::entity_type
Entity entity_type
Underlying entity identifier.
Definition: view.hpp:332
entt::basic_view< Entity, exclude_t<>, Component >::data
const entity_type * data() const noexcept
Direct access to the list of entities.
Definition: view.hpp:867
entt::basic_view< Entity, exclude_t<>, Component >::size
size_type size() const noexcept
Returns the number of entities that have the given component.
Definition: view.hpp:827