pub struct Archetype { /* private fields */ }
Expand description
A container for all entities with a particular set of components.
Each component has a corresponding columnm of contiguous data in this archetype. Each row in is then a separate entity.
For instance, an archetype with component set {A, B, C}
might look like:
Entity ID | Column A | Column B | Column C |
---|---|---|---|
Entity 0 | “foo” | 123 | true |
Entity 1 | “bar” | 456 | false |
Entity 2 | “baz” | 789 | true |
Implementations§
source§impl Archetype
impl Archetype
sourcepub fn index(&self) -> ArchetypeIdx
pub fn index(&self) -> ArchetypeIdx
Returns the index of this archetype.
sourcepub fn entity_count(&self) -> u32
pub fn entity_count(&self) -> u32
Returns the total number of entities in this archetype.
sourcepub fn entity_ids(&self) -> &[EntityId]
pub fn entity_ids(&self) -> &[EntityId]
Returns a slice of EntityId
s for all the entities in this archetype.
sourcepub fn component_indices(&self) -> &[ComponentIdx]
pub fn component_indices(&self) -> &[ComponentIdx]
Returns a sorted slice of component types for every column in this archetype.
The returned slice has the same length as the slice returned by
columns
.
sourcepub fn columns(&self) -> &[Column]
pub fn columns(&self) -> &[Column]
Returns a slice of columns sorted by ComponentIdx
.
sourcepub fn column_of(&self, idx: ComponentIdx) -> Option<&Column>
pub fn column_of(&self, idx: ComponentIdx) -> Option<&Column>
Finds the column with the given component. Returns None
if it doesn’t
exist.
Trait Implementations§
impl RefUnwindSafe for Archetype
impl Send for Archetype
impl Sync for Archetype
impl UnwindSafe for Archetype
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more