Expand description
Implementations
sourceimpl<T> UnionFind<T, HashMap<T, T>, ()> where
T: Clone + Hash + Eq,
impl<T> UnionFind<T, HashMap<T, T>, ()> where
T: Clone + Hash + Eq,
sourcepub fn new_hashmap(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, AddError>
pub fn new_hashmap(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, AddError>
Constructs a new union find, using a hashmap as backing
sourceimpl<T> UnionFind<T, BTreeMap<T, T>, ()> where
T: Clone + Ord,
impl<T> UnionFind<T, BTreeMap<T, T>, ()> where
T: Clone + Ord,
sourcepub fn new_btreemap(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, AddError>
pub fn new_btreemap(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, AddError>
Constructs a new union find, using a btreemap as backing
sourceimpl<T, M, E> UnionFind<T, M, E> where
M: ParentMapping<T>,
T: Clone,
E: Extra<T>,
impl<T, M, E> UnionFind<T, M, E> where
M: ParentMapping<T>,
T: Clone,
E: Extra<T>,
sourcepub fn new(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, NewUnionFindError<<M as ParentMapping<T>>::Err, <E as Extra<T>>::ConstructErr>>
pub fn new(
elems: impl IntoIterator<Item = T> + Clone
) -> Result<Self, NewUnionFindError<<M as ParentMapping<T>>::Err, <E as Extra<T>>::ConstructErr>>
Constructs a new union find, allowing you to specify all type parameters.
sourceimpl<T: PartialEq, M: Mapping<T, T>, E> UnionFind<T, M, E>
impl<T: PartialEq, M: Mapping<T, T>, E> UnionFind<T, M, E>
sourcepub fn find(&self, elem: &T) -> Option<T> where
T: Clone,
pub fn find(&self, elem: &T) -> Option<T> where
T: Clone,
Find an element in the union find. Performs no path shortening, but can be used through an immutable reference.
Use [find_shorten] for a more efficient find.
sourcepub fn find_shorten(&mut self, elem: &T) -> Option<T> where
T: Clone,
pub fn find_shorten(&mut self, elem: &T) -> Option<T> where
T: Clone,
Find an element in the union find. Performs path shortening, which means you need mutable access to the union find.
Use [find] for an immutable version.
sourceimpl<T: PartialEq, ParentMapping: Mapping<T, T>> UnionFind<T, ParentMapping, ()> where
ParentMapping: Mapping<T, T>,
impl<T: PartialEq, ParentMapping: Mapping<T, T>> UnionFind<T, ParentMapping, ()> where
ParentMapping: Mapping<T, T>,
sourcepub fn union_by<U: Union<T>>(
&mut self,
elem1: &T,
elem2: &T,
union: U
) -> Result<UnionStatus, UnionError<U::Err>> where
T: Clone,
pub fn union_by<U: Union<T>>(
&mut self,
elem1: &T,
elem2: &T,
union: U
) -> Result<UnionStatus, UnionError<U::Err>> where
T: Clone,
union two elements in the union find
sourceimpl<T: PartialEq, ParentMapping: Mapping<T, T>, RankMapping> UnionFind<T, ParentMapping, ByRank<RankMapping, T>> where
ParentMapping: Mapping<T, T>,
RankMapping: Mapping<T, usize>,
T: Clone,
impl<T: PartialEq, ParentMapping: Mapping<T, T>, RankMapping> UnionFind<T, ParentMapping, ByRank<RankMapping, T>> where
ParentMapping: Mapping<T, T>,
RankMapping: Mapping<T, usize>,
T: Clone,
sourcepub fn union_by_rank(
&mut self,
elem1: &T,
elem2: &T
) -> Result<UnionStatus, UnionByRankError>
pub fn union_by_rank(
&mut self,
elem1: &T,
elem2: &T
) -> Result<UnionStatus, UnionByRankError>
union two elements in the union find
Auto Trait Implementations
impl<T, M, E> RefUnwindSafe for UnionFind<T, M, E> where
E: RefUnwindSafe,
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M, E> Send for UnionFind<T, M, E> where
E: Send,
M: Send,
T: Send,
impl<T, M, E> Sync for UnionFind<T, M, E> where
E: Sync,
M: Sync,
T: Sync,
impl<T, M, E> Unpin for UnionFind<T, M, E> where
E: Unpin,
M: Unpin,
T: Unpin,
impl<T, M, E> UnwindSafe for UnionFind<T, M, E> where
E: UnwindSafe,
M: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more