pub struct ReverseIndex { /* private fields */ }Expand description
Reverse-reference index over a model snapshot.
A value from ReverseIndex::build reflects the model as it was when
built: mutating the model afterwards does not update it, and the borrow
checker enforces that for the common &Model case. The one behind
Model::reverse_index is kept current by the model’s writes.
Implementations§
Source§impl ReverseIndex
impl ReverseIndex
Sourcepub fn build(model: &Model) -> Self
pub fn build(model: &Model) -> Self
Scan every entity once and record each reference by target.
Sourcepub fn build_from(
model: &Model,
referrers: impl IntoIterator<Item = EntityId>,
) -> Self
pub fn build_from( model: &Model, referrers: impl IntoIterator<Item = EntityId>, ) -> Self
The references held by referrers only, in one pass over them.
For every target, ReverseIndex::referrers equals what
ReverseIndex::build reports for it, restricted to those
entities: the same slots, ascending. Ids the model does not hold are
skipped, and an id repeated counts once. A caller that knows which
record types can point at what it asks about pays for those records,
not for the model (#608).
Sourcepub fn referrers(&self, target: EntityId) -> &[Referrer]
pub fn referrers(&self, target: EntityId) -> &[Referrer]
Every reference pointing at target, in ascending (from, slot) order.
Sourcepub fn referrers_in_slot(
&self,
target: EntityId,
slot: usize,
) -> impl Iterator<Item = EntityId> + '_
pub fn referrers_in_slot( &self, target: EntityId, slot: usize, ) -> impl Iterator<Item = EntityId> + '_
Entities referencing target from the given attribute slot.
This is the query objectified relationships need: “which relationship entities name me in their RelatingStructure slot”.
Sourcepub fn is_referenced(&self, target: EntityId) -> bool
pub fn is_referenced(&self, target: EntityId) -> bool
Whether anything references target.
Trait Implementations§
Source§impl Clone for ReverseIndex
impl Clone for ReverseIndex
Source§fn clone(&self) -> ReverseIndex
fn clone(&self) -> ReverseIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more