pub struct UnionFind { /* private fields */ }Expand description
A union-find (disjoint-set) data structure with path compression.
Implementations§
Source§impl UnionFind
impl UnionFind
Sourcepub fn union(&mut self, x: usize, y: usize) -> bool
pub fn union(&mut self, x: usize, y: usize) -> bool
Unions the classes of x and y. Returns true if they were distinct.
Sourcepub fn same(&mut self, x: usize, y: usize) -> bool
pub fn same(&mut self, x: usize, y: usize) -> bool
Returns true if x and y are in the same class.
Sourcepub fn num_classes(&self) -> usize
pub fn num_classes(&self) -> usize
Returns the number of distinct classes.
Sourcepub fn num_elements(&self) -> usize
pub fn num_elements(&self) -> usize
Returns the total number of elements.
Auto Trait Implementations§
impl Freeze for UnionFind
impl RefUnwindSafe for UnionFind
impl Send for UnionFind
impl Sync for UnionFind
impl Unpin for UnionFind
impl UnsafeUnpin 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