pub struct UnionFind { /* private fields */ }
Expand description
Vector-based union-find representing a set of disjoint sets.
Implementations§
Source§impl UnionFind
impl UnionFind
pub fn with_size(size: usize) -> Self
pub fn with_ranks(ranks: Vec<usize>) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn extend(&mut self, size: usize)
Sourcepub fn find(&mut self, element: usize) -> usize
pub fn find(&mut self, element: usize) -> usize
Finds the representative element for the given element’s set.
pub fn in_same_set(&mut self, a: usize, b: usize) -> bool
pub fn parent(&self, element: usize) -> usize
pub fn set_parent(&mut self, element: usize, parent: usize)
Trait Implementations§
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