pub trait SingletonInverseVariableSupply<V, E>: Supply{
// Required methods
fn get_inverse_singleton(&self, value: &V) -> Option<E>;
fn insert(&self, value: V, entity: E);
fn remove(&self, value: &V) -> Option<E>;
fn clear(&self);
fn len(&self) -> usize;
// Provided methods
fn update(&self, old_value: Option<&V>, new_value: V, entity: E) { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Supply that provides O(1) lookup of the entity pointing to a value.
For a chained variable where entity.previous = value, this supply answers:
“Given value, which entity has entity.previous == value?”
This is essential for efficient chain manipulation in moves.
Required Methods§
Sourcefn get_inverse_singleton(&self, value: &V) -> Option<E>
fn get_inverse_singleton(&self, value: &V) -> Option<E>
Gets the entity that points to the given value, if any.
Returns None if no entity currently points to this value.
Sourcefn insert(&self, value: V, entity: E)
fn insert(&self, value: V, entity: E)
Registers that an entity now points to a value.
Called when a variable change causes entity.var = value.