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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more