|
void | reserve (const size_type cap) |
| Increases the capacity of a storage. More...
|
|
void | shrink_to_fit () |
| Requests the removal of unused capacity. More...
|
|
const object_type * | raw () const ENTT_NOEXCEPT |
| Direct access to the array of objects. More...
|
|
object_type * | raw () ENTT_NOEXCEPT |
| Direct access to the array of objects. More...
|
|
const_iterator_type | cbegin () const ENTT_NOEXCEPT |
| Returns an iterator to the beginning. More...
|
|
const_iterator_type | begin () const ENTT_NOEXCEPT |
| Returns an iterator to the beginning. More...
|
|
iterator_type | begin () ENTT_NOEXCEPT |
| Returns an iterator to the beginning. More...
|
|
const_iterator_type | cend () const ENTT_NOEXCEPT |
| Returns an iterator to the end. More...
|
|
const_iterator_type | end () const ENTT_NOEXCEPT |
| Returns an iterator to the end. More...
|
|
iterator_type | end () ENTT_NOEXCEPT |
| Returns an iterator to the end. More...
|
|
const object_type & | get (const entity_type entt) const ENTT_NOEXCEPT |
| Returns the object associated with an entity. More...
|
|
object_type & | get (const entity_type entt) ENTT_NOEXCEPT |
| Returns the object associated with an entity. More...
|
|
const object_type * | try_get (const entity_type entt) const ENTT_NOEXCEPT |
| Returns a pointer to the object associated with an entity, if any. More...
|
|
object_type * | try_get (const entity_type entt) ENTT_NOEXCEPT |
| Returns a pointer to the object associated with an entity, if any. More...
|
|
template<typename... Args> |
object_type & | construct (const entity_type entt, Args &&... args) |
| Assigns an entity to a storage and constructs its object. More...
|
|
template<typename It , typename... Args> |
iterator_type | batch (It first, It last, Args &&... args) |
| Assigns one or more entities to a storage and default constructs or copy constructs their objects. More...
|
|
void | destroy (const entity_type entt) |
| Removes an entity from a storage and destroys its object. More...
|
|
void | swap (const entity_type lhs, const entity_type rhs) ENTT_NOEXCEPT override |
| Swaps entities and objects in the internal packed arrays. More...
|
|
template<typename Compare , typename Sort = std_sort, typename... Args> |
void | sort (iterator_type first, iterator_type last, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort elements according to the given comparison function. More...
|
|
void | reset () |
| Resets a storage. More...
|
|
| sparse_set ()=default |
| Default constructor. More...
|
|
| sparse_set (const sparse_set &other) |
| Copy constructor. More...
|
|
| sparse_set (sparse_set &&)=default |
| Default move constructor. More...
|
|
virtual | ~sparse_set () ENTT_NOEXCEPT=default |
| Default destructor. More...
|
|
sparse_set & | operator= (const sparse_set &other) |
| Copy assignment operator. More...
|
|
sparse_set & | operator= (sparse_set &&)=default |
| Default move assignment operator. More...
|
|
void | reserve (const size_type cap) |
| Increases the capacity of a sparse set. More...
|
|
size_type | capacity () const ENTT_NOEXCEPT |
| Returns the number of elements that a sparse set has currently allocated space for. More...
|
|
void | shrink_to_fit () |
| Requests the removal of unused capacity. More...
|
|
size_type | extent () const ENTT_NOEXCEPT |
| Returns the extent of a sparse set. More...
|
|
size_type | size () const ENTT_NOEXCEPT |
| Returns the number of elements in a sparse set. More...
|
|
bool | empty () const ENTT_NOEXCEPT |
| Checks whether a sparse set is empty. More...
|
|
const entity_type * | data () const ENTT_NOEXCEPT |
| Direct access to the internal packed array. More...
|
|
iterator_type | begin () const ENTT_NOEXCEPT |
| Returns an iterator to the beginning. More...
|
|
iterator_type | end () const ENTT_NOEXCEPT |
| Returns an iterator to the end. More...
|
|
iterator_type | find (const entity_type entt) const ENTT_NOEXCEPT |
| Finds an entity. More...
|
|
bool | has (const entity_type entt) const ENTT_NOEXCEPT |
| Checks if a sparse set contains an entity. More...
|
|
size_type | index (const entity_type entt) const ENTT_NOEXCEPT |
| Returns the position of an entity in a sparse set. More...
|
|
void | construct (const entity_type entt) |
| Assigns an entity to a sparse set. More...
|
|
template<typename It > |
void | batch (It first, It last) |
| Assigns one or more entities to a sparse set. More...
|
|
void | destroy (const entity_type entt) |
| Removes an entity from a sparse set. More...
|
|
template<typename Compare , typename Sort = std_sort, typename... Args> |
void | sort (iterator_type first, iterator_type last, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort elements according to the given comparison function. More...
|
|
template<typename Apply , typename Compare , typename Sort = std_sort, typename... Args> |
void | arrange (iterator_type first, iterator_type last, Apply apply, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort elements according to the given comparison function. More...
|
|
void | respect (const sparse_set &other) ENTT_NOEXCEPT |
| Sort entities according to their order in another sparse set. More...
|
|
void | reset () |
| Resets a sparse set. More...
|
|
template<typename Entity, typename Type, typename = std::void_t<>>
class entt::basic_storage< Entity, Type, typename >
Basic storage implementation.
This class is a refinement of a sparse set that associates an object to an entity. The main purpose of this class is to extend sparse sets to store components in a registry. It guarantees fast access both to the elements and to the entities.
- Note
- Entities and objects have the same order. It's guaranteed both in case of raw access (either to entities or objects) and when using random or input access iterators.
-
Internal data structures arrange elements to maximize performance. Because of that, there are no guarantees that elements have the expected order when iterate directly the internal packed array (see
raw
and size
member functions for that). Use begin
and end
instead.
- Warning
- Empty types aren't explicitly instantiated. Temporary objects are returned in place of the instances of the components and raw access isn't available for them.
- See also
- sparse_set<Entity>
- Template Parameters
-
Entity | A valid entity type (see entt_traits for more details). |
Type | Type of objects assigned to the entities. |
template<typename Entity , typename Type , typename = std::void_t<>>
template<typename Compare , typename Sort = std_sort, typename... Args>
Sort elements according to the given comparison function.
Sort the elements so that iterating the range with a couple of iterators returns them in the expected order. See begin
and end
for more details.
The comparison function object must return true
if the first element is less than the second one, false
otherwise. The signature of the comparison function should be equivalent to one of the following:
bool(const Entity, const Entity);
bool(const Type &, const Type &);
Moreover, the comparison function object shall induce a strict weak ordering on the values.
The sort function oject must offer a member function template operator()
that accepts three arguments:
- An iterator to the first element of the range to sort.
- An iterator past the last element of the range to sort.
- A comparison function to use to compare the elements.
- Note
- Attempting to iterate elements using a raw pointer returned by a call to either
data
or raw
gives no guarantees on the order, even though sort
has been invoked.
- Warning
- Empty types are never instantiated. Therefore, only comparison function objects that require to return entities rather than components are accepted.
- Template Parameters
-
Compare | Type of comparison function object. |
Sort | Type of sort function object. |
Args | Types of arguments to forward to the sort function object. |
- Parameters
-
first | An iterator to the first element of the range to sort. |
last | An iterator past the last element of the range to sort. |
compare | A valid comparison function object. |
algo | A valid sort function object. |
args | Arguments to forward to the sort function object, if any. |