EnTT  3.5.2
group.hpp
1 #ifndef ENTT_ENTITY_GROUP_HPP
2 #define ENTT_ENTITY_GROUP_HPP
3 
4 
5 #include <tuple>
6 #include <utility>
7 #include <type_traits>
8 #include "../config/config.h"
9 #include "../core/type_traits.hpp"
10 #include "entity.hpp"
11 #include "fwd.hpp"
12 #include "pool.hpp"
13 #include "sparse_set.hpp"
14 #include "utility.hpp"
15 
16 
17 namespace entt {
18 
19 
26 template<typename...>
27 class basic_group;
28 
29 
66 template<typename Entity, typename... Exclude, typename... Get>
67 class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> {
69  friend class basic_registry<Entity>;
70 
71  template<typename Component>
72  using pool_type = pool_t<Entity, Component>;
73 
74  class group_proxy {
75  friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>>;
76 
77  class proxy_iterator {
78  friend class group_proxy;
79 
80  using it_type = typename sparse_set<Entity>::iterator;
81  using ref_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<pool_type<Get> *>>>()...));
82 
83  proxy_iterator(it_type from, ref_type ref) ENTT_NOEXCEPT
84  : it{from},
85  pools{ref}
86  {}
87 
88  public:
89  using difference_type = std::ptrdiff_t;
90  using value_type = decltype(std::tuple_cat(
91  std::declval<std::tuple<Entity>>(),
92  std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<Get>>>()...
93  ));
94  using pointer = void;
95  using reference = decltype(std::tuple_cat(
96  std::declval<std::tuple<Entity>>(),
97  std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<Get &>>>()...
98  ));
99  using iterator_category = std::input_iterator_tag;
100 
101  proxy_iterator & operator++() ENTT_NOEXCEPT {
102  return ++it, *this;
103  }
104 
105  proxy_iterator operator++(int) ENTT_NOEXCEPT {
106  proxy_iterator orig = *this;
107  return ++(*this), orig;
108  }
109 
110  [[nodiscard]] reference operator*() const ENTT_NOEXCEPT {
111  return std::apply([entt = *it](auto *... cpool) { return reference{entt, cpool->get(entt)...}; }, pools);
112  }
113 
114  [[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
115  return other.it == it;
116  }
117 
118  [[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
119  return !(*this == other);
120  }
121 
122  private:
123  it_type it{};
124  ref_type pools{};
125  };
126 
127  group_proxy(const sparse_set<Entity> &ref, std::tuple<pool_type<Get> *...> gpools)
128  : handler{&ref},
129  pools{gpools}
130  {}
131 
132  public:
133  using iterator = proxy_iterator;
134 
135  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
136  return proxy_iterator{handler->begin(), std::tuple_cat([](auto *cpool) {
137  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
138  return std::make_tuple();
139  } else {
140  return std::make_tuple(cpool);
141  }
142  }(std::get<pool_type<Get> *>(pools))...)};
143  }
144 
145  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
146  return proxy_iterator{handler->end(), std::tuple_cat([](auto *cpool) {
147  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
148  return std::make_tuple();
149  } else {
150  return std::make_tuple(cpool);
151  }
152  }(std::get<pool_type<Get> *>(pools))...)};
153  }
154 
155  private:
156  const sparse_set<Entity> *handler;
157  std::tuple<pool_type<Get> *...> pools;
158  };
159 
160  basic_group(sparse_set<Entity> &ref, pool_type<Get> &... gpool) ENTT_NOEXCEPT
161  : handler{&ref},
162  pools{&gpool...}
163  {}
164 
165  template<typename Func, typename... Weak>
166  void traverse(Func func, type_list<Weak...>) const {
167  for(const auto entt: *handler) {
168  if constexpr(std::is_invocable_v<Func, decltype(get<Weak>({}))...>) {
169  func(std::get<pool_type<Weak> *>(pools)->get(entt)...);
170  } else {
171  func(entt, std::get<pool_type<Weak> *>(pools)->get(entt)...);
172  }
173  }
174  }
175 
176 public:
178  using entity_type = Entity;
180  using size_type = std::size_t;
185 
191  template<typename Component>
192  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
193  return std::get<pool_type<Component> *>(pools)->size();
194  }
195 
200  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
201  return handler->size();
202  }
203 
209  [[nodiscard]] size_type capacity() const ENTT_NOEXCEPT {
210  return handler->capacity();
211  }
212 
214  void shrink_to_fit() {
215  handler->shrink_to_fit();
216  }
217 
223  template<typename... Component>
224  [[nodiscard]] bool empty() const ENTT_NOEXCEPT {
225  if constexpr(sizeof...(Component) == 0) {
226  return handler->empty();
227  } else {
228  return (std::get<pool_type<Component> *>(pools)->empty() && ...);
229  }
230  }
231 
246  template<typename Component>
247  [[nodiscard]] Component * raw() const ENTT_NOEXCEPT {
248  return std::get<pool_type<Component> *>(pools)->raw();
249  }
250 
265  template<typename Component>
266  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
267  return std::get<pool_type<Component> *>(pools)->data();
268  }
269 
282  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
283  return handler->data();
284  }
285 
298  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
299  return handler->begin();
300  }
301 
316  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
317  return handler->end();
318  }
319 
332  [[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
333  return handler->rbegin();
334  }
335 
351  [[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
352  return handler->rend();
353  }
354 
360  [[nodiscard]] entity_type front() const {
361  const auto it = begin();
362  return it != end() ? *it : null;
363  }
364 
370  [[nodiscard]] entity_type back() const {
371  const auto it = rbegin();
372  return it != rend() ? *it : null;
373  }
374 
381  [[nodiscard]] iterator find(const entity_type entt) const {
382  const auto it = handler->find(entt);
383  return it != end() && *it == entt ? it : end();
384  }
385 
391  [[nodiscard]] entity_type operator[](const size_type pos) const {
392  return begin()[pos];
393  }
394 
400  [[nodiscard]] bool contains(const entity_type entt) const {
401  return handler->contains(entt);
402  }
403 
421  template<typename... Component>
422  [[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) const {
423  ENTT_ASSERT(contains(entt));
424 
425  if constexpr(sizeof...(Component) == 1) {
426  return (std::get<pool_type<Component> *>(pools)->get(entt), ...);
427  } else {
428  return std::tuple<decltype(get<Component>({}))...>{get<Component>(entt)...};
429  }
430  }
431 
454  template<typename Func>
455  void each(Func func) const {
457  traverse(std::move(func), get_type_list{});
458  }
459 
473  [[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
474  return group_proxy{*handler, pools};
475  }
476 
513  template<typename... Component, typename Compare, typename Sort = std_sort, typename... Args>
514  void sort(Compare compare, Sort algo = Sort{}, Args &&... args) {
515  if constexpr(sizeof...(Component) == 0) {
516  static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
517  handler->sort(handler->begin(), handler->end(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
518  } else if constexpr(sizeof...(Component) == 1) {
519  handler->sort(handler->begin(), handler->end(), [this, compare = std::move(compare)](const entity_type lhs, const entity_type rhs) {
520  return compare((std::get<pool_type<Component> *>(pools)->get(lhs), ...), (std::get<pool_type<Component> *>(pools)->get(rhs), ...));
521  }, std::move(algo), std::forward<Args>(args)...);
522  } else {
523  handler->sort(handler->begin(), handler->end(), [this, compare = std::move(compare)](const entity_type lhs, const entity_type rhs) {
524  return compare(std::tuple<decltype(get<Component>({}))...>{std::get<pool_type<Component> *>(pools)->get(lhs)...}, std::tuple<decltype(get<Component>({}))...>{std::get<pool_type<Component> *>(pools)->get(rhs)...});
525  }, std::move(algo), std::forward<Args>(args)...);
526  }
527  }
528 
545  template<typename Component>
546  void sort() const {
547  handler->respect(*std::get<pool_type<Component> *>(pools));
548  }
549 
550 private:
551  sparse_set<entity_type> *handler;
552  const std::tuple<pool_type<Get> *...> pools;
553 };
554 
555 
602 template<typename Entity, typename... Exclude, typename... Get, typename... Owned>
603 class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> {
605  friend class basic_registry<Entity>;
606 
607  template<typename Component>
608  using pool_type = pool_t<Entity, Component>;
609 
610  template<typename Component>
611  using component_iterator = decltype(std::declval<pool_type<Component>>().begin());
612 
613  class group_proxy {
614  friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...>;
615 
616  class proxy_iterator {
617  friend class group_proxy;
618 
619  using it_type = typename sparse_set<Entity>::iterator;
620  using owned_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Owned>, std::tuple<>, std::tuple<component_iterator<Owned>>>>()...));
621  using get_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<pool_type<Get> *>>>()...));
622 
623  proxy_iterator(it_type from, owned_type oref, get_type gref) ENTT_NOEXCEPT
624  : it{from},
625  owned{oref},
626  get{gref}
627  {}
628 
629  public:
630  using difference_type = std::ptrdiff_t;
631  using value_type = decltype(std::tuple_cat(
632  std::declval<std::tuple<Entity>>(),
633  std::declval<std::conditional_t<is_eto_eligible_v<Owned>, std::tuple<>, std::tuple<Owned>>>()...,
634  std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<Get>>>()...
635  ));
636  using pointer = void;
637  using reference = decltype(std::tuple_cat(
638  std::declval<std::tuple<Entity>>(),
639  std::declval<std::conditional_t<is_eto_eligible_v<Owned>, std::tuple<>, std::tuple<Owned &>>>()...,
640  std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<Get &>>>()...
641  ));
642  using iterator_category = std::input_iterator_tag;
643 
644  proxy_iterator & operator++() ENTT_NOEXCEPT {
645  return ++it, std::apply([](auto &&... curr) { (++curr, ...); }, owned), *this;
646  }
647 
648  proxy_iterator operator++(int) ENTT_NOEXCEPT {
649  proxy_iterator orig = *this;
650  return ++(*this), orig;
651  }
652 
653  [[nodiscard]] reference operator*() const ENTT_NOEXCEPT {
654  return std::tuple_cat(
655  std::make_tuple(*it),
656  std::apply([](auto &&... curr) { return std::forward_as_tuple(*curr...); }, owned),
657  std::apply([entt = *it](auto &&... curr) { return std::forward_as_tuple(curr->get(entt)...); }, get)
658  );
659  }
660 
661  [[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
662  return other.it == it;
663  }
664 
665  [[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
666  return !(*this == other);
667  }
668 
669  private:
670  it_type it{};
671  owned_type owned{};
672  get_type get{};
673  };
674 
675  group_proxy(std::tuple<pool_type<Owned> *..., pool_type<Get> *...> cpools, const std::size_t &extent)
676  : pools{cpools},
677  length{&extent}
678  {}
679 
680  public:
681  using iterator = proxy_iterator;
682 
683  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
684  return proxy_iterator{
685  std::get<0>(pools)->sparse_set<Entity>::end() - *length,
686  std::tuple_cat([length = *length](auto *cpool) {
687  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
688  return std::make_tuple();
689  } else {
690  return std::make_tuple(cpool->end() - length);
691  }
692  }(std::get<pool_type<Owned> *>(pools))...),
693  std::tuple_cat([](auto *cpool) {
694  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
695  return std::make_tuple();
696  } else {
697  return std::make_tuple(cpool);
698  }
699  }(std::get<pool_type<Get> *>(pools))...)
700  };
701  }
702 
703  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
704  return proxy_iterator{
705  std::get<0>(pools)->sparse_set<Entity>::end(),
706  std::tuple_cat([](auto *cpool) {
707  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
708  return std::make_tuple();
709  } else {
710  return std::make_tuple(cpool->end());
711  }
712  }(std::get<pool_type<Owned> *>(pools))...),
713  std::tuple_cat([](auto *cpool) {
714  if constexpr(is_eto_eligible_v<typename std::decay_t<decltype(*cpool)>::object_type>) {
715  return std::make_tuple();
716  } else {
717  return std::make_tuple(cpool);
718  }
719  }(std::get<pool_type<Get> *>(pools))...)
720  };
721  }
722 
723  private:
724  const std::tuple<pool_type<Owned> *..., pool_type<Get> *...> pools;
725  const std::size_t *length;
726  };
727 
728  basic_group(const std::size_t &extent, pool_type<Owned> &... opool, pool_type<Get> &... gpool) ENTT_NOEXCEPT
729  : pools{&opool..., &gpool...},
730  length{&extent}
731  {}
732 
733  template<typename Func, typename... Strong, typename... Weak>
734  void traverse(Func func, type_list<Strong...>, type_list<Weak...>) const {
735  [[maybe_unused]] auto it = std::make_tuple((std::get<pool_type<Strong> *>(pools)->end() - *length)...);
736  [[maybe_unused]] auto data = std::get<0>(pools)->sparse_set<entity_type>::end() - *length;
737 
738  for(auto next = *length; next; --next) {
739  if constexpr(std::is_invocable_v<Func, decltype(get<Strong>({}))..., decltype(get<Weak>({}))...>) {
740  if constexpr(sizeof...(Weak) == 0) {
741  func(*(std::get<component_iterator<Strong>>(it)++)...);
742  } else {
743  const auto entt = *(data++);
744  func(*(std::get<component_iterator<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
745  }
746  } else {
747  const auto entt = *(data++);
748  func(entt, *(std::get<component_iterator<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
749  }
750  }
751  }
752 
753 public:
755  using entity_type = Entity;
757  using size_type = std::size_t;
762 
768  template<typename Component>
769  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
770  return std::get<pool_type<Component> *>(pools)->size();
771  }
772 
777  [[nodiscard]] size_type size() const ENTT_NOEXCEPT {
778  return *length;
779  }
780 
786  template<typename... Component>
787  [[nodiscard]] bool empty() const ENTT_NOEXCEPT {
788  if constexpr(sizeof...(Component) == 0) {
789  return !*length;
790  } else {
791  return (std::get<pool_type<Component> *>(pools)->empty() && ...);
792  }
793  }
794 
812  template<typename Component>
813  [[nodiscard]] Component * raw() const ENTT_NOEXCEPT {
814  return std::get<pool_type<Component> *>(pools)->raw();
815  }
816 
834  template<typename Component>
835  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
836  return std::get<pool_type<Component> *>(pools)->data();
837  }
838 
851  [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
852  return std::get<0>(pools)->data();
853  }
854 
867  [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
868  return std::get<0>(pools)->sparse_set<entity_type>::end() - *length;
869  }
870 
885  [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
886  return std::get<0>(pools)->sparse_set<entity_type>::end();
887  }
888 
901  [[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
902  return std::get<0>(pools)->sparse_set<entity_type>::rbegin();
903  }
904 
920  [[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
921  return std::get<0>(pools)->sparse_set<entity_type>::rbegin() + *length;
922  }
923 
929  [[nodiscard]] entity_type front() const {
930  const auto it = begin();
931  return it != end() ? *it : null;
932  }
933 
939  [[nodiscard]] entity_type back() const {
940  const auto it = rbegin();
941  return it != rend() ? *it : null;
942  }
943 
950  [[nodiscard]] iterator find(const entity_type entt) const {
951  const auto it = std::get<0>(pools)->find(entt);
952  return it != end() && it >= begin() && *it == entt ? it : end();
953  }
954 
960  [[nodiscard]] entity_type operator[](const size_type pos) const {
961  return begin()[pos];
962  }
963 
969  [[nodiscard]] bool contains(const entity_type entt) const {
970  return std::get<0>(pools)->contains(entt) && (std::get<0>(pools)->index(entt) < (*length));
971  }
972 
990  template<typename... Component>
991  [[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) const {
992  ENTT_ASSERT(contains(entt));
993 
994  if constexpr(sizeof...(Component) == 1) {
995  return (std::get<pool_type<Component> *>(pools)->get(entt), ...);
996  } else {
997  return std::tuple<decltype(get<Component>({}))...>{get<Component>(entt)...};
998  }
999  }
1000 
1023  template<typename Func>
1024  void each(Func func) const {
1027  traverse(std::move(func), owned_type_list{}, get_type_list{});
1028  }
1029 
1043  [[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
1044  return group_proxy{pools, *length};
1045  }
1046 
1084  template<typename... Component, typename Compare, typename Sort = std_sort, typename... Args>
1085  void sort(Compare compare, Sort algo = Sort{}, Args &&... args) {
1086  auto *cpool = std::get<0>(pools);
1087 
1088  if constexpr(sizeof...(Component) == 0) {
1089  static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
1090  cpool->sort(cpool->end()-*length, cpool->end(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
1091  } else if constexpr(sizeof...(Component) == 1) {
1092  cpool->sort(cpool->end()-*length, cpool->end(), [this, compare = std::move(compare)](const entity_type lhs, const entity_type rhs) {
1093  return compare((std::get<pool_type<Component> *>(pools)->get(lhs), ...), (std::get<pool_type<Component> *>(pools)->get(rhs), ...));
1094  }, std::move(algo), std::forward<Args>(args)...);
1095  } else {
1096  cpool->sort(cpool->end()-*length, cpool->end(), [this, compare = std::move(compare)](const entity_type lhs, const entity_type rhs) {
1097  return compare(std::tuple<decltype(get<Component>({}))...>{std::get<pool_type<Component> *>(pools)->get(lhs)...}, std::tuple<decltype(get<Component>({}))...>{std::get<pool_type<Component> *>(pools)->get(rhs)...});
1098  }, std::move(algo), std::forward<Args>(args)...);
1099  }
1100 
1101  [this](auto *head, auto *... other) {
1102  for(auto next = *length; next; --next) {
1103  const auto pos = next - 1;
1104  [[maybe_unused]] const auto entt = head->data()[pos];
1105  (other->swap(other->data()[pos], entt), ...);
1106  }
1107  }(std::get<pool_type<Owned> *>(pools)...);
1108  }
1109 
1110 private:
1111  const std::tuple<pool_type<Owned> *..., pool_type<Get> *...> pools;
1112  const size_type *length;
1113 };
1114 
1115 
1116 }
1117 
1118 
1119 #endif
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::reverse_iterator
typename sparse_set< Entity >::reverse_iterator reverse_iterator
Reversed iterator type.
Definition: group.hpp:761
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::reverse_iterator
typename sparse_set< Entity >::reverse_iterator reverse_iterator
Reversed iterator type.
Definition: group.hpp:184
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::data
const entity_type * data() const noexcept
Direct access to the list of entities of a given pool.
Definition: group.hpp:835
entt::type_list
A class to use to push around lists of types, nothing more.
Definition: type_traits.hpp:77
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::iterator
typename sparse_set< Entity >::iterator iterator
Random access iterator type.
Definition: group.hpp:182
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::find
iterator find(const entity_type entt) const
Finds an entity.
Definition: group.hpp:950
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::rbegin
reverse_iterator rbegin() const noexcept
Returns an iterator to the first entity of the reversed group.
Definition: group.hpp:901
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::end
iterator end() const noexcept
Returns an iterator that is past the last entity of the group.
Definition: group.hpp:316
entt::sparse_set< entity_type >
entt::get
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: utility.hpp:40
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::begin
iterator begin() const noexcept
Returns an iterator to the first entity of the group.
Definition: group.hpp:298
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::data
const entity_type * data() const noexcept
Direct access to the list of entities.
Definition: group.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::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_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::back
entity_type back() const
Returns the last entity of the group, if any.
Definition: group.hpp:370
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::sort
void sort(Compare compare, Sort algo=Sort{}, Args &&... args)
Sort a group according to the given comparison function.
Definition: group.hpp:514
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::each
void each(Func func) const
Iterates entities and components and applies the given function object to them.
Definition: group.hpp:455
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::capacity
size_type capacity() const noexcept
Returns the number of elements that a group has currently allocated space for.
Definition: group.hpp:209
entt::sparse_set::iterator
sparse_set_iterator iterator
Random access iterator type.
Definition: sparse_set.hpp:182
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::data
const entity_type * data() const noexcept
Direct access to the list of entities.
Definition: group.hpp:282
entt::basic_group
Group.
Definition: fwd.hpp:24
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::entity_type
Entity entity_type
Underlying entity identifier.
Definition: group.hpp:755
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::proxy
auto proxy() const noexcept
Returns an iterable object to use to visit the group.
Definition: group.hpp:473
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::rend
reverse_iterator rend() const noexcept
Returns an iterator that is past the last entity of the reversed group.
Definition: group.hpp:351
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::size_type
std::size_t size_type
Unsigned integer type.
Definition: group.hpp:757
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::begin
iterator begin() const noexcept
Returns an iterator to the first entity of the group.
Definition: group.hpp:867
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::front
entity_type front() const
Returns the first entity of the group, if any.
Definition: group.hpp:929
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::end
iterator end() const noexcept
Returns an iterator that is past the last entity of the group.
Definition: group.hpp:885
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::size
size_type size() const noexcept
Returns the number of existing components of the given type.
Definition: group.hpp:769
entt
EnTT default namespace.
Definition: algorithm.hpp:13
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::raw
Component * raw() const noexcept
Direct access to the list of components of a given pool.
Definition: group.hpp:247
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::operator[]
entity_type operator[](const size_type pos) const
Returns the identifier that occupies the given position.
Definition: group.hpp:960
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::rbegin
reverse_iterator rbegin() const noexcept
Returns an iterator to the first entity of the reversed group.
Definition: group.hpp:332
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::size
size_type size() const noexcept
Returns the number of entities that have the given components.
Definition: group.hpp:777
entt::is_eto_eligible_v
constexpr auto is_eto_eligible_v
Helper variable template.
Definition: type_traits.hpp:225
entt::get_t
Alias for lists of observed components.
Definition: utility.hpp:32
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::contains
bool contains(const entity_type entt) const
Checks if a group contains an entity.
Definition: group.hpp:400
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::operator[]
entity_type operator[](const size_type pos) const
Returns the identifier that occupies the given position.
Definition: group.hpp:391
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::sort
void sort(Compare compare, Sort algo=Sort{}, Args &&... args)
Sort a group according to the given comparison function.
Definition: group.hpp:1085
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::back
entity_type back() const
Returns the last entity of the group, if any.
Definition: group.hpp:939
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::size
size_type size() const noexcept
Returns the number of entities that have the given components.
Definition: group.hpp:200
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::sort
void sort() const
Sort the shared pool of entities according to the given component.
Definition: group.hpp:546
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::raw
Component * raw() const noexcept
Direct access to the list of components of a given pool.
Definition: group.hpp:813
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::proxy
auto proxy() const noexcept
Returns an iterable object to use to visit the group.
Definition: group.hpp:1043
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::contains
bool contains(const entity_type entt) const
Checks if a group contains an entity.
Definition: group.hpp:969
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::empty
bool empty() const noexcept
Checks whether a group or some pools are empty.
Definition: group.hpp:224
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::find
iterator find(const entity_type entt) const
Finds an entity.
Definition: group.hpp:381
entt::basic_registry
Fast and reliable entity-component system.
Definition: registry.hpp:43
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::rend
reverse_iterator rend() const noexcept
Returns an iterator that is past the last entity of the reversed group.
Definition: group.hpp:920
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::data
const entity_type * data() const noexcept
Direct access to the list of entities of a given pool.
Definition: group.hpp:266
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::front
entity_type front() const
Returns the first entity of the group, if any.
Definition: group.hpp:360
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::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::size_type
std::size_t size_type
Unsigned integer type.
Definition: group.hpp:180
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::empty
bool empty() const noexcept
Checks whether a group or some pools are empty.
Definition: group.hpp:787
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:158
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::entity_type
Entity entity_type
Underlying entity identifier.
Definition: group.hpp:178
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::size
size_type size() const noexcept
Returns the number of existing components of the given type.
Definition: group.hpp:192
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... > >::shrink_to_fit
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: group.hpp:214
entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::iterator
typename sparse_set< Entity >::iterator iterator
Random access iterator type.
Definition: group.hpp:759
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_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >::each
void each(Func func) const
Iterates entities and components and applies the given function object to them.
Definition: group.hpp:1024
entt::std_sort
Function object to wrap std::sort in a class type.
Definition: algorithm.hpp:24