pub struct StaticTreeSetUnion { /* private fields */ }Expand description
Static tree set union data structure (Gabow-Tarjan Section 2).
The tree must be known in advance. Supports link and find operations
in O(1) amortized time, with O(m + n) total for m operations on n nodes.
§Semantics
- Initially every node is its own set name (marked).
link(v)removesvas a set name, merging it intoparent(v)’s set. After this,findwill skip pastv.find(v)returns the nearest ancestor ofvthat is still a set name (has not been linked). A node is its own ancestor.link(root)panics: the root has no parent.
Implementations§
Source§impl StaticTreeSetUnion
impl StaticTreeSetUnion
Sourcepub fn from_parents(parents: &[usize]) -> Self
pub fn from_parents(parents: &[usize]) -> Self
Construct from a parent array. parents[i] is the parent of node i.
The root node must satisfy parents[root] == root.
Sourcepub fn link(&mut self, v: usize)
pub fn link(&mut self, v: usize)
Link node v: remove v as a set name, merging it into its
parent’s set.
Sourcepub fn find(&mut self, v: usize) -> usize
pub fn find(&mut self, v: usize) -> usize
Find the nearest ancestor of v that is still a set name
(has not been linked). A node is its own ancestor.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for StaticTreeSetUnion
impl Clone for StaticTreeSetUnion
Source§fn clone(&self) -> StaticTreeSetUnion
fn clone(&self) -> StaticTreeSetUnion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StaticTreeSetUnion
impl RefUnwindSafe for StaticTreeSetUnion
impl Send for StaticTreeSetUnion
impl Sync for StaticTreeSetUnion
impl Unpin for StaticTreeSetUnion
impl UnsafeUnpin for StaticTreeSetUnion
impl UnwindSafe for StaticTreeSetUnion
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