pub struct UnionFind { /* private fields */ }Expand description
Union-Find (Disjoint Set Union) with path compression and union by rank.
This is the optimal data structure for incremental connectivity queries, providing nearly O(1) amortized operations.
Implementations§
Source§impl UnionFind
impl UnionFind
Sourcepub fn find(&mut self, x: usize) -> usize
pub fn find(&mut self, x: usize) -> usize
Finds the representative (root) of the set containing x.
Uses path compression for amortized O(α(n)) complexity.
Auto Trait Implementations§
impl Freeze for UnionFind
impl RefUnwindSafe for UnionFind
impl Send for UnionFind
impl Sync for UnionFind
impl Unpin for UnionFind
impl UnwindSafe for UnionFind
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