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]

[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.

[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.

[src]

Returns true if x and y is in the same set, otherwise false.

Panics

If x or y is not in any set.

[src]

Returns the representative of the set that contains x.

Panics

If x is not in any set.

[src]

Returns the number of distinct sets.

impl<K: Copy + Hash + Eq> UnionFind<K>
[src]

[src]

Creates a new UnionFind.

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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more