[−][src]Struct competitive_hpp::union_find::UnionFind
UnionFind
Example:
use competitive_hpp::prelude::*; // 0 ━━━━━ 1 ━━━━━ 4 // // 2 ━━━━━ 3 let mut uf = UnionFind::new(5usize); uf.union(0, 1); uf.union(2, 3); uf.union(1, 4); assert_eq!(uf.find(0), uf.find(1)); assert_eq!(2, uf.num_of_groups()); assert!(uf.is_same(0, 1)); assert_eq!(uf.rank(2), 0); assert_eq!(uf.group_size(0), 3);
Implementations
impl<T> UnionFind<T> where
T: PrimInt + NumAssignOps + Unsigned,
[src]
T: PrimInt + NumAssignOps + Unsigned,
pub fn new(n: T) -> Self
[src]
pub fn find(&mut self, x: T) -> T
[src]
pub fn union(&mut self, x: T, y: T)
[src]
pub fn is_same(&mut self, x: T, y: T) -> bool
[src]
pub fn group_size(&mut self, x: T) -> T
[src]
pub fn rank(&self, x: T) -> T
[src]
pub fn num_of_groups(&self) -> T
[src]
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for UnionFind<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for UnionFind<T> where
T: Send,
T: Send,
impl<T> Sync for UnionFind<T> where
T: Sync,
T: Sync,
impl<T> Unpin for UnionFind<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for UnionFind<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,