pub struct UnionFind<Key, Parent = IndexedHashMap<Key, Key>, Rank = IndexedHashMap<Key, usize>>where
Key: Copy + PartialEq,
Parent: IndexMut<Key, Output = Key>,
Rank: IndexMut<Key, Output = usize>,{ /* private fields */ }Expand description
A union-find (disjoint-set) struct.
Implementations§
Source§impl<Key, Parent, Rank> UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> UnionFind<Key, Parent, Rank>
Sourcepub fn make_set(&mut self, x: Key)
pub fn make_set(&mut self, x: Key)
Adds the key in it’s own set. The number of sets is increased by 1.
It’s undefined behavior to call this method with a key that is already in a set.
Sourcepub fn union(&mut self, x: Key, y: Key)
pub fn union(&mut self, x: Key, y: Key)
Joins the sets with the keys x and y. The number of sets is decreased by 1.
§Panics
If x or y is not in any set or if both are in the same set.
Sourcepub fn in_same_set(&mut self, x: Key, y: Key) -> bool
pub fn in_same_set(&mut self, x: Key, y: Key) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<Key, Parent, Rank> Freeze for UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> RefUnwindSafe for UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> Send for UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> Sync for UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> Unpin for UnionFind<Key, Parent, Rank>
impl<Key, Parent, Rank> UnwindSafe for UnionFind<Key, Parent, Rank>
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