pub struct UnionFind { /* private fields */ }Expand description
A union-find data structure. The data structure can allocate
Ids, indicating eclasses, and can merge eclasses together.
Implementations§
Source§impl UnionFind
impl UnionFind
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Create a new UnionFind with the given capacity.
Sourcepub fn add(&mut self, id: Id)
pub fn add(&mut self, id: Id)
Add an Id to the UnionFind, with its own equivalence class
initially. All Ids must be added before being queried or
unioned.
Sourcepub fn find_and_update(&mut self, node: Id) -> Id
pub fn find_and_update(&mut self, node: Id) -> Id
Find the canonical Id of a given Id, updating the data
structure in the process so that future queries for this Id
(and others in its chain up to the root of the equivalence
class) will be faster.
Sourcepub fn equiv_id_mut(&mut self, a: Id, b: Id) -> bool
pub fn equiv_id_mut(&mut self, a: Id, b: Id) -> bool
Determine if two Ids are equivalent, after
canonicalizing. Update union-find data structure during our
canonicalization to make future lookups faster.
Sourcepub fn hash_id_mut<H: Hasher>(&mut self, hash: &mut H, id: Id)
pub fn hash_id_mut<H: Hasher>(&mut self, hash: &mut H, id: Id)
Hash an Id after canonicalizing it. Update union-find data
structure to make future lookups/hashing faster.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UnionFind
impl RefUnwindSafe for UnionFind
impl Send for UnionFind
impl Sync for UnionFind
impl Unpin for UnionFind
impl UnwindSafe for UnionFind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more