pub struct UnionFind<Value> { /* private fields */ }Expand description
A basic implementation of a union-find datastructure.
Implementations§
Source§impl<Value: NumericId> UnionFind<Value>
impl<Value: NumericId> UnionFind<Value>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the union-find data-structure to the point where all Ids are their own parents.
Sourcepub fn union(&mut self, a: Value, b: Value) -> (Value, Value)
pub fn union(&mut self, a: Value, b: Value) -> (Value, Value)
Merge two equivalence classes.
Sourcepub fn find_naive(&self, id: Value) -> Value
pub fn find_naive(&self, id: Value) -> Value
Find the representative of an equivalence class without using path compression.
The primary advantage of this method is that it allows the ability to answer find queries
without holding a mutable reference to the union-find.
Trait Implementations§
Auto Trait Implementations§
impl<Value> Freeze for UnionFind<Value>
impl<Value> RefUnwindSafe for UnionFind<Value>where
Value: RefUnwindSafe,
impl<Value> Send for UnionFind<Value>where
Value: Send,
impl<Value> Sync for UnionFind<Value>where
Value: Sync,
impl<Value> Unpin for UnionFind<Value>where
Value: Unpin,
impl<Value> UnwindSafe for UnionFind<Value>where
Value: UnwindSafe,
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
Mutably borrows from an owned value. Read more