pub struct EntityTable { /* private fields */ }Expand description
The entity table.
Canonical sequences share one pool rather than owning a collection each, so a structure with three hundred entities holds one allocation for their sequences instead of three hundred.
Implementations§
Source§impl EntityTable
impl EntityTable
Sourcepub fn push(
&mut self,
id: SymbolId,
kind: EntityKind,
description: OptionalSymbol,
canonical_sequence: &[SymbolId],
) -> Result<EntityIndex, CapacityError>
pub fn push( &mut self, id: SymbolId, kind: EntityKind, description: OptionalSymbol, canonical_sequence: &[SymbolId], ) -> Result<EntityIndex, CapacityError>
Appends an entity, returning its position.
§Errors
Returns CapacityError when the entity table exceeds its index space.
Sourcepub fn push_without_id(
&mut self,
kind: EntityKind,
description: OptionalSymbol,
canonical_sequence: &[SymbolId],
) -> Result<EntityIndex, CapacityError>
pub fn push_without_id( &mut self, kind: EntityKind, description: OptionalSymbol, canonical_sequence: &[SymbolId], ) -> Result<EntityIndex, CapacityError>
Appends an entity whose source did not declare an identifier.
§Errors
Returns CapacityError when the entity table exceeds its index space.
Sourcepub fn kind(&self, entity: EntityIndex) -> Option<EntityKind>
pub fn kind(&self, entity: EntityIndex) -> Option<EntityKind>
What kind of species this entity is.
Sourcepub fn id(&self, entity: EntityIndex) -> Option<SymbolId>
pub fn id(&self, entity: EntityIndex) -> Option<SymbolId>
The identifier the file gave this entity.
Sourcepub fn find_by_id(&self, id: SymbolId) -> Option<EntityIndex>
pub fn find_by_id(&self, id: SymbolId) -> Option<EntityIndex>
The entity carrying id, where the file declared one.
Entity tables are normally small and this is used while building one chain at a time, not in an atom loop. Keeping the lookup here avoids a second index whose lifetime and invalidation would duplicate the table.
Sourcepub fn description(&self, entity: EntityIndex) -> Option<SymbolId>
pub fn description(&self, entity: EntityIndex) -> Option<SymbolId>
The entity’s description, if the file carried one.
Sourcepub fn canonical_sequence(&self, entity: EntityIndex) -> &[SymbolId]
pub fn canonical_sequence(&self, entity: EntityIndex) -> &[SymbolId]
The sequence this entity should have, one component per position.
Compare it against the residues a chain actually holds to find what was not modelled.
Sourcepub fn iter(&self) -> impl Iterator<Item = EntityIndex> + '_
pub fn iter(&self) -> impl Iterator<Item = EntityIndex> + '_
Every entity position.
Trait Implementations§
Source§impl Clone for EntityTable
impl Clone for EntityTable
Source§impl Debug for EntityTable
impl Debug for EntityTable
Auto Trait Implementations§
impl Freeze for EntityTable
impl RefUnwindSafe for EntityTable
impl Send for EntityTable
impl Sync for EntityTable
impl Unpin for EntityTable
impl UnsafeUnpin for EntityTable
impl UnwindSafe for EntityTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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