Struct sprs::linalg::etree::Parents

source ·
pub struct Parents<S>where
    S: Deref<Target = [Parent]>,{ /* private fields */ }
Expand description

Store an etree as the parent information of each node. This reflects the fact that etrees can in fact have multiple roots.

Implementations§

source§

impl<S: Deref<Target = [Parent]>> Parents<S>

source

pub fn get_parent(&self, node: usize) -> Option<usize>

Get the parent of a node. Returns None if the node is a root.

Panics
  • if node is out of bounds
source

pub fn is_root(&self, node: usize) -> bool

Test whether a node is a root.

Panics
  • if node is out of bounds
source

pub fn nb_nodes(&self) -> usize

The number of nodes in this tree.

source

pub fn view(&self) -> ParentsView<'_>

Get a view of this object

source§

impl<S: DerefMut<Target = [Parent]>> Parents<S>

source

pub fn set_parent(&mut self, node: usize, parent: usize)

Set the parent of a node.

Panics
  • if node is out of bounds
  • if parent is out of bounds
source

pub fn set_root(&mut self, node: usize)

Set a node as a root.

Panics
  • if node is out of bounds
source

pub fn uproot(&mut self, node: usize, parent: usize)

Give a parent to a root of the tree. No-op if the node was not a parent.

Panics

if either node or parent is out of bounds

source

pub fn view_mut(&mut self) -> ParentsViewMut<'_>

source§

impl Parents<Vec<Option<usize>, Global>>

source

pub fn new(nb_nodes: usize) -> Self

Create a new tree with all nodes set as root

Trait Implementations§

source§

impl<S> Clone for Parents<S>where S: Deref<Target = [Parent]> + Clone,

source§

fn clone(&self) -> Parents<S>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<S> Debug for Parents<S>where S: Deref<Target = [Parent]> + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Parents<S>where S: RefUnwindSafe,

§

impl<S> Send for Parents<S>where S: Send,

§

impl<S> Sync for Parents<S>where S: Sync,

§

impl<S> Unpin for Parents<S>where S: Unpin,

§

impl<S> UnwindSafe for Parents<S>where S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.