SingletonInverseVariableSupply

Trait SingletonInverseVariableSupply 

Source
pub trait SingletonInverseVariableSupply<V, E>: Supply
where V: Eq + Hash + Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static,
{ // 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§

Source

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.

Source

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.

Source

fn remove(&self, value: &V) -> Option<E>

Removes the mapping for a value.

Called when the entity that pointed to this value changes.

Source

fn clear(&self)

Clears all mappings.

Source

fn len(&self) -> usize

Returns the number of tracked mappings.

Provided Methods§

Source

fn update(&self, old_value: Option<&V>, new_value: V, entity: E)

Updates the mapping: removes old value mapping, adds new.

Source

fn is_empty(&self) -> bool

Returns true if no mappings exist.

Implementors§

Source§

impl<V, E> SingletonInverseVariableSupply<V, E> for ExternalizedSingletonInverseVariableSupply<V, E>
where V: Eq + Hash + Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static,