Struct PotentialUnionFind

Source
pub struct PotentialUnionFind<T> { /* private fields */ }
Expand description

ポテンシャル付きUnionfind

Implementations§

Source§

impl<T> PotentialUnionFind<T>
where T: AbelianGroup + Clone,

Source

pub fn new_commutative(n: usize) -> Self

大きさnPotentialUnionFindを生成する。(ポテンシャルが可換群のとき)

Source§

impl<T> PotentialUnionFind<T>
where T: Group + Clone,

Source

pub fn new_non_commutative(n: usize) -> Self

大きさnPotentialUnionFindを生成する。(ポテンシャルが可換とは限らない群のとき)

Source

pub fn root_of(&self, i: usize) -> usize

iの属する素集合の根を返す。

Source

pub fn potential_of(&self, i: usize) -> T

iのポテンシャル($P(i)$)を返す。

Source

pub fn is_same(&self, i: usize, j: usize) -> bool

ijが同じ素集合に属するならばtrueを返す。

Source

pub fn diff(&self, i: usize, j: usize) -> Option<T>

ijが同一の素集合に属するとき、ポテンシャルの差($P(i) - P(j)$)を返す。

Source

pub fn merge(&mut self, i: usize, j: usize, p: T) -> usize

iの属する素集合とjの属する素集合を統合する。 統合後は、$P(i) = P(j) + p$を満たす。

Source

pub fn size_of(&self, i: usize) -> usize

iの属する素集合の大きさを返す。

Source

pub fn count_groups(&self) -> usize

素集合の個数を返す。

Source

pub fn get_groups(&self) -> Vec<Vec<usize>>

素集合をすべて列挙する。

Auto Trait Implementations§

§

impl<T> !Freeze for PotentialUnionFind<T>

§

impl<T> !RefUnwindSafe for PotentialUnionFind<T>

§

impl<T> Send for PotentialUnionFind<T>
where T: Send,

§

impl<T> !Sync for PotentialUnionFind<T>

§

impl<T> Unpin for PotentialUnionFind<T>
where T: Unpin,

§

impl<T> UnwindSafe for PotentialUnionFind<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.