|
| basic_sparse_set ()=default |
| Default constructor.
|
|
| basic_sparse_set (basic_sparse_set &&)=default |
| Default move constructor.
|
|
virtual | ~basic_sparse_set ()=default |
| Default destructor.
|
|
basic_sparse_set & | operator= (basic_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.
|
|
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 | begin () const ENTT_NOEXCEPT |
| Returns an iterator to the beginning. More...
|
|
iterator | end () const ENTT_NOEXCEPT |
| Returns an iterator to the end. More...
|
|
reverse_iterator | rbegin () const ENTT_NOEXCEPT |
| Returns a reverse iterator to the beginning. More...
|
|
reverse_iterator | rend () const ENTT_NOEXCEPT |
| Returns a reverse iterator to the end. More...
|
|
iterator | find (const entity_type entt) const |
| Finds an entity. More...
|
|
bool | contains (const entity_type entt) const |
| Checks if a sparse set contains an entity. More...
|
|
size_type | index (const entity_type entt) const |
| Returns the position of an entity in a sparse set. More...
|
|
void | emplace (const entity_type entt) |
| Assigns an entity to a sparse set. More...
|
|
template<typename It > |
void | insert (It first, It last) |
| Assigns one or more entities to a sparse set. More...
|
|
void | remove (const entity_type entt) |
| Removes an entity from a sparse set. More...
|
|
template<typename It > |
void | remove (It first, It last) |
| Removes multiple entities from a pool. More...
|
|
void | swap (const entity_type lhs, const entity_type rhs) |
| Swaps two entities in the internal packed array. More...
|
|
template<typename Compare , typename Sort = std_sort, typename... Args> |
void | sort_n (const size_type count, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort the first count elements according to the given comparison function. More...
|
|
template<typename Compare , typename Sort = std_sort, typename... Args> |
void | sort (Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort all elements according to the given comparison function. More...
|
|
void | respect (const basic_sparse_set &other) |
| Sort entities according to their order in another sparse set. More...
|
|
void | clear () ENTT_NOEXCEPT |
| Clears a sparse set.
|
|
template<typename Entity>
class entt::basic_sparse_set< Entity >
Basic sparse set implementation.
Sparse set or packed array or whatever is the name users give it.
Two arrays: an external one and an internal one; a sparse one and a packed one; one used for direct access through contiguous memory, the other one used to get the data through an extra level of indirection.
This is largely used by the registry to offer users the fastest access ever to the components. Views and groups in general are almost entirely designed around sparse sets.
This type of data structure is widely documented in the literature and on the web. This is nothing more than a customized implementation suitable for the purpose of the framework.
- Note
- Internal data structures arrange elements to maximize performance. There are no guarantees that entities are returned in the insertion order when iterate a sparse set. Do not make assumption on the order in any case.
- Template Parameters
-
Entity | A valid entity type (see entt_traits for more details). |
template<typename Entity>
Sort entities according to their order in another sparse set.
Entities that are part of both the sparse sets are ordered internally according to the order they have in other
. All the other entities goes to the end of the list and there are no guarantees on their order.
In other terms, this function can be used to impose the same order on two sets by using one of them as a master and the other one as a slave.
Iterating the sparse set with a couple of iterators returns elements in the expected order after a call to respect
. See begin
and end
for more details.
- Parameters
-
other | The sparse sets that imposes the order of the entities. |
template<typename Entity>
template<typename Compare , typename Sort = std_sort, typename... Args>
Sort the first count elements according to the given comparison function.
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 the following:
bool(const Entity, const Entity);
Moreover, the comparison function object shall induce a strict weak ordering on the values.
The sort function object 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.
- 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
-
count | Number of elements 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. |