Struct fera_unionfind::UnionFind
[−]
[src]
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>, { /* fields omitted */ }
A union-find (disjoint-set) struct.
Methods
impl<Key, Parent, Rank> UnionFind<Key, Parent, Rank> where
Key: Copy + PartialEq,
Parent: IndexMut<Key, Output = Key>,
Rank: IndexMut<Key, Output = usize>,
[src]
Key: Copy + PartialEq,
Parent: IndexMut<Key, Output = Key>,
Rank: IndexMut<Key, Output = usize>,
fn make_set(&mut self, x: Key)
[src]
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.
fn union(&mut self, x: Key, y: Key)
[src]
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.
fn in_same_set(&mut self, x: Key, y: Key) -> bool
[src]
fn find_set(&mut self, x: Key) -> Key
[src]
fn num_sets(&self) -> usize
[src]
Returns the number of distinct sets.
impl<K: Copy + Hash + Eq> UnionFind<K>
[src]
Trait Implementations
impl<Key: Clone, Parent: Clone, Rank: Clone> Clone for UnionFind<Key, Parent, Rank> where
Key: Copy + PartialEq,
Parent: IndexMut<Key, Output = Key>,
Rank: IndexMut<Key, Output = usize>,
[src]
Key: Copy + PartialEq,
Parent: IndexMut<Key, Output = Key>,
Rank: IndexMut<Key, Output = usize>,