Struct visioncortex::disjoint_sets::Forests[][src]

pub struct Forests<T> where
    T: Eq + Hash
{ /* fields omitted */ }

Data structure for building disjoint sets

Implementations

impl<T> Forests<T> where
    T: Eq + Hash
[src]

pub fn new() -> Self[src]

pub fn count_sets(&mut self) -> usize[src]

Counts the number of unique disjoint sets.

pub fn group_items(&mut self, items: &[T]) -> Vec<Vec<usize>>[src]

Groups items by their containing sets. The result is the indices of items in the provided items that belongs to different disjoint sets. The order of groups is arbitrary. Items that do not exist in the forest belongs to the same group that does not consist of other contained items.

pub fn make_set(&mut self, item: T)[src]

Makes a new singleton set with exactly one element item.

pub fn find_set(&mut self, item: &T) -> Option<Label>[src]

Find the label of the set item belongs to.

pub fn union(&mut self, item1: &T, item2: &T)[src]

Unions the two sets containing item1 and item2. No-op if either item1 or item2 is not present (i.e. no make_set has been made).

Trait Implementations

impl<T> Default for Forests<T> where
    T: Eq + Hash
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Forests<T> where
    T: RefUnwindSafe

impl<T> Send for Forests<T> where
    T: Send

impl<T> Sync for Forests<T> where
    T: Sync

impl<T> Unpin for Forests<T> where
    T: Unpin

impl<T> UnwindSafe for Forests<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.