Struct spirt::EntityDefs
source · pub struct EntityDefs<E: Entity> {
complete_chunk_start_to_flattened_base: FxHashMap<E, usize>,
incomplete_chunk_start_and_flattened_base: Option<(E, usize)>,
flattened: Vec<E::Def>,
}
Expand description
Collection holding the actual definitions for Context
-allocated entities.
By design there is no way to iterate the contents of an EntityDefs
, or
generate entity indices without defining the entity in an EntityDefs
.
Fields§
§complete_chunk_start_to_flattened_base: FxHashMap<E, usize>
Entities are grouped into chunks, with per-entity-type chunk sizes
(powers of 2) specified via entities!
below.
This allows different EntityDefs
s to independently define more
entities, without losing compactness (until a whole chunk is filled).
incomplete_chunk_start_and_flattened_base: Option<(E, usize)>
Similar to a single entry in complete_chunk_start_to_flattened_base
,
but kept outside of the map for efficiency. Also, this is the only
chunk that doesn’t have its full size already (and therefore allows
defining more entities into it, without allocating new chunks).
flattened: Vec<E::Def>
All chunks’ definitions are flattened into one contiguous Vec
, where
the start of each chunk’s definitions in flattened
is indicated by
either complete_chunk_start_to_flattened_base
(for completed chunks)
or incomplete_chunk_start_and_flattened_base
.
Implementations§
Trait Implementations§
source§impl<E: Clone + Entity> Clone for EntityDefs<E>
impl<E: Clone + Entity> Clone for EntityDefs<E>
source§fn clone(&self) -> EntityDefs<E>
fn clone(&self) -> EntityDefs<E>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more