pub struct UnionFind<T: Hash + Eq + Clone> { /* private fields */ }Expand description
Disjoint-set union–find with union by rank and path compression.
Implementations§
Source§impl<T: Hash + Eq + Clone> UnionFind<T>
impl<T: Hash + Eq + Clone> UnionFind<T>
Sourcepub fn new(elements: impl IntoIterator<Item = T>) -> Self
pub fn new(elements: impl IntoIterator<Item = T>) -> Self
Create a new union–find structure for the given elements.
Sourcepub fn find(&mut self, x: &T) -> Result<T, Error>
pub fn find(&mut self, x: &T) -> Result<T, Error>
Return the representative of the set containing x.
Sourcepub fn union(&mut self, x: &T, y: &T) -> Result<bool, Error>
pub fn union(&mut self, x: &T, y: &T) -> Result<bool, Error>
Merge the sets containing x and y.
Auto Trait Implementations§
impl<T> Freeze for UnionFind<T>
impl<T> RefUnwindSafe for UnionFind<T>
impl<T> Send for UnionFind<T>
impl<T> Sync for UnionFind<T>
impl<T> Unpin for UnionFind<T>
impl<T> UnsafeUnpin for UnionFind<T>
impl<T> UnwindSafe for UnionFind<T>
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