pub type InPlaceUnificationTable<K: UnifyKey, V: VecLike<Delegate<K>> = Vec<VarValue<K>>, L = VecLog<UndoLog<Delegate<K>>>> = UnificationTable<InPlace<K, V, L>>;
Expand description

A unification table that uses an “in-place” vector.

Aliased Type§

struct InPlaceUnificationTable<K: UnifyKey, V: VecLike<Delegate<K>> = Vec<VarValue<K>>, L = VecLog<UndoLog<Delegate<K>>>> { /* private fields */ }

Implementations

source§

impl<K> UnificationTable<InPlace<K, Vec<VarValue<K>>, ()>>where K: UnifyKey,

source

pub fn with_log<'a, L>( &'a mut self, undo_log: L ) -> UnificationTable<InPlace<K, &'a mut UnificationStorage<K>, L>>where L: UndoLogs<UndoLog<Delegate<K>>>,

Creates a UnificationTable using an external undo_log, allowing mutating methods to be called if L does not implement UndoLogs

source§

impl<S: UnificationStoreBase + Default> UnificationTable<S>

source

pub fn new() -> Self

source§

impl<S: UnificationStore> UnificationTable<S>

source

pub fn snapshot(&mut self) -> Snapshot<S>

Starts a new snapshot. Each snapshot must be either rolled back or committed in a “LIFO” (stack) order.

source

pub fn rollback_to(&mut self, snapshot: Snapshot<S>)

Reverses all changes since the last snapshot. Also removes any keys that have been created since then.

source

pub fn commit(&mut self, snapshot: Snapshot<S>)

Commits all changes since the last snapshot. Of course, they can still be undone if there is a snapshot further out.

source

pub fn vars_since_snapshot(&self, snapshot: &Snapshot<S>) -> Range<S::Key>

Returns the keys of all variables created since the snapshot.

source§

impl<S: UnificationStoreBase> UnificationTable<S>

source

pub fn len(&self) -> usize

Returns the number of keys created so far.

source§

impl<S: UnificationStoreMut> UnificationTable<S>

source

pub fn new_key(&mut self, value: S::Value) -> S::Key

Starts a new snapshot. Each snapshot must be either Creates a fresh key with the given value.

source

pub fn reserve(&mut self, num_new_keys: usize)

Reserve memory for num_new_keys to be created. Does not actually create the new keys; you must then invoke new_key.

source

pub fn reset_unifications(&mut self, value: impl FnMut(S::Key) -> S::Value)

Clears all unifications that have been performed, resetting to the initial state. The values of each variable are given by the closure.

source§

impl<S, K, V> UnificationTable<S>where S: UnificationStoreBase<Key = K, Value = V>, K: UnifyKey<Value = V>, V: UnifyValue,

//////////////////////////////////////////////////////////////////////// Public API

source

pub fn try_probe_value<'a, K1>(&'a self, id: K1) -> Option<&'a V>where K1: Into<K>, K: 'a,

Obtains current value for key without any pointer chasing; may return None if key has been union’d.

source§

impl<S, K, V> UnificationTable<S>where S: UnificationStoreMut<Key = K, Value = V>, K: UnifyKey<Value = V>, V: UnifyValue,

source

pub fn union<K1, K2>(&mut self, a_id: K1, b_id: K2)where K1: Into<K>, K2: Into<K>, V: UnifyValue<Error = NoError>,

Unions two keys without the possibility of failure; only applicable when unify values use NoError as their error type.

source

pub fn union_value<K1>(&mut self, id: K1, value: V)where K1: Into<K>, V: UnifyValue<Error = NoError>,

Unions a key and a value without the possibility of failure; only applicable when unify values use NoError as their error type.

source

pub fn unioned<K1, K2>(&mut self, a_id: K1, b_id: K2) -> boolwhere K1: Into<K>, K2: Into<K>,

Given two keys, indicates whether they have been unioned together.

source

pub fn find<K1>(&mut self, id: K1) -> Kwhere K1: Into<K>,

Given a key, returns the (current) root key.

source

pub fn unify_var_var<K1, K2>( &mut self, a_id: K1, b_id: K2 ) -> Result<(), V::Error>where K1: Into<K>, K2: Into<K>,

Unions together two variables, merging their values. If merging the values fails, the error is propagated and this method has no effect.

source

pub fn unify_var_value<K1>(&mut self, a_id: K1, b: V) -> Result<(), V::Error>where K1: Into<K>,

Sets the value of the key a_id to b, attempting to merge with the previous value.

source

pub fn probe_value<K1>(&mut self, id: K1) -> Vwhere K1: Into<K>,

Returns the current value for the given key. If the key has been union’d, this will give the value from the current root.

source

pub fn inlined_probe_value<K1>(&mut self, id: K1) -> Vwhere K1: Into<K>,

Trait Implementations

source§

impl<S: Debug + UnificationStoreBase> Debug for UnificationTable<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: Clone + UnificationStoreBase> Clone for UnificationTable<S>

source§

fn clone(&self) -> UnificationTable<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Default + UnificationStoreBase> Default for UnificationTable<S>

source§

fn default() -> UnificationTable<S>

Returns the “default value” for a type. Read more