Skip to main content

DisjointSetArrayU32

Struct DisjointSetArrayU32 

Source
pub struct DisjointSetArrayU32<const SIZE: usize>(/* private fields */);

Implementations§

Source§

impl<const SIZE: usize> DisjointSetArrayU32<SIZE>

Source

pub fn new() -> Self

Creates new disjoint set. Does not compile if SIZE too big:

use aph_disjoint_set::DisjointSetArrayU8;
let _: DisjointSetArrayU8<500> = DisjointSetArrayU8::new();
#[cfg(miri)] // Miri doesn't catch compile error because it doesn't evaluate code in such tests.
let _: u32 = 0u64;
Source

pub fn initialize_inplace(memory: &mut MaybeUninit<Self>) -> &mut Self

Initializes some memory with default state of disjoint set and returns reference to it. Useful if you want hard guarantee that compiler doesn’t allocate some place on stack for temporary value during moves.

Does not compile if SIZE too big:

use core::mem::MaybeUninit;
use aph_disjoint_set::DisjointSetArrayU8;

let mut value: MaybeUninit<DisjointSetArrayU8<500>> = MaybeUninit::uninit();
DisjointSetArrayU8::initialize_inplace(&mut value);
#[cfg(miri)] // Miri doesn't catch compile error because it doesn't evaluate code in such tests.
let _: u32 = 0u64;
§Example
use core::mem::MaybeUninit;
use aph_disjoint_set::DisjointSetArrayU8;

let mut value: MaybeUninit<DisjointSetArrayU8<10>> = MaybeUninit::uninit();
let djs = DisjointSetArrayU8::initialize_inplace(&mut value);
djs.union(9, 1);
assert!(djs.is_united(1, 9));
Source§

impl<const SIZE: usize> DisjointSetArrayU32<SIZE>

Source

pub fn get_root(&mut self, idx: usize) -> Root

Same as DisjointSet::get_root.

§Panics

If index is out of bounds.

Source

pub fn union(&mut self, idx0: usize, idx1: usize) -> UnionResult

Same as DisjointSet::union.

§Panics

If any index is out of bounds.

Source

pub fn is_united(&mut self, idx0: usize, idx1: usize) -> bool

Same as DisjointSet::is_united.

§Panics

If any index is out of bounds.

Source

pub fn detach(&mut self, idx: usize)

Same as DisjointSet::detach.

§Panics

If index is out of bounds.

Source

pub fn split_at(&mut self, split_idx: usize) -> (ChunkMut<'_>, ChunkMut<'_>)

Source

pub fn make_ro_view(&mut self) -> DisjointSetRoView<'_>

Source

pub fn into_readonly(self) -> RoDisjointSetArrayU32<SIZE>

Source

pub fn compress_paths(&mut self)

Source

pub fn reset(&mut self)

Trait Implementations§

Source§

impl<const SIZE: usize> Clone for DisjointSetArrayU32<SIZE>

Source§

fn clone(&self) -> DisjointSetArrayU32<SIZE>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const SIZE: usize> Default for DisjointSetArrayU32<SIZE>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const SIZE: usize> From<RoDisjointSetArrayU32<SIZE>> for DisjointSetArrayU32<SIZE>

Source§

fn from(value: RoDisjointSetArrayU32<SIZE>) -> Self

Converts to this type from the input type.
Source§

impl<const SIZE: usize> Copy for DisjointSetArrayU32<SIZE>

Auto Trait Implementations§

§

impl<const SIZE: usize> Freeze for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> RefUnwindSafe for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> Send for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> Sync for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> Unpin for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> UnsafeUnpin for DisjointSetArrayU32<SIZE>

§

impl<const SIZE: usize> UnwindSafe for DisjointSetArrayU32<SIZE>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.