Trait union_find::UnionFind
[−]
[src]
pub trait UnionFind<V: Union>: FromIterator<V> + Extend<V> + Sized { fn size(&self) -> usize; fn insert(&mut self, data: V) -> usize; fn union(&mut self, key0: usize, key1: usize) -> bool; fn find(&mut self, key: usize) -> usize; fn get(&mut self, key: usize) -> &V; fn get_mut(&mut self, key: usize) -> &mut V; fn new(len: usize) -> Self
where
V: Default, { ... } }
APIs for Union-Find operation.
Required Methods
fn size(&self) -> usize
Returns the size of self
.
fn insert(&mut self, data: V) -> usize
Inserts a new set into the union.
Returns the key of the inserted set.
fn union(&mut self, key0: usize, key1: usize) -> bool
Join two sets that contains given keys (union operation).
Returns true
if these keys are belonged to different sets.
fn find(&mut self, key: usize) -> usize
Returns the identifier of the set that the key belongs to.
fn get(&mut self, key: usize) -> &V
Returns the reference to the value of the set that the key belongs to.
fn get_mut(&mut self, key: usize) -> &mut V
Returns the mutable reference to the value of the set that the key belongs to.
Provided Methods
Implementors
impl<V: Union> UnionFind<V> for QuickUnionUf<V>
impl<V: Union> UnionFind<V> for QuickFindUf<V>