pub struct Hierarchy<T>where
T: Debug,{ /* private fields */ }
Expand description
A hierarchy of nodes, each of which has a data of the type of the tree
Implementations§
Source§impl<T> Hierarchy<T>where
T: Debug,
impl<T> Hierarchy<T>where
T: Debug,
Sourcepub fn relate(&mut self, parent: usize, child: usize)
pub fn relate(&mut self, parent: usize, child: usize)
Add a relation from a parent to a child in the hierarchy
Sourcepub fn find_roots(&mut self)
pub fn find_roots(&mut self)
Find all the roots of the hierarchy and record it
Sourcepub fn borrow_node(&self, index: usize) -> &T
pub fn borrow_node(&self, index: usize) -> &T
Borrow a node in the hierarchy
Sourcepub fn borrow_mut(&mut self) -> (&Vec<usize>, &mut Vec<Node<T>>)
pub fn borrow_mut(&mut self) -> (&Vec<usize>, &mut Vec<Node<T>>)
Mutuably borrow a node in the hierarchy
Sourcepub fn borrow_roots(&self) -> &Vec<usize>
pub fn borrow_roots(&self) -> &Vec<usize>
Borrow the roots of the hierarchy
Sourcepub fn enum_from(&self, node: usize) -> NodeEnum<'_, T> ⓘ
pub fn enum_from(&self, node: usize) -> NodeEnum<'_, T> ⓘ
Enumerate the nodes from a particular node
Sourcepub fn iter_from(&self, node: usize) -> NodeIter<'_, T> ⓘ
pub fn iter_from(&self, node: usize) -> NodeIter<'_, T> ⓘ
Iterate the nodes from a particular node
Sourcepub fn borrow_elements(&self) -> &Vec<Node<T>>
pub fn borrow_elements(&self) -> &Vec<Node<T>>
Borrow all the elements
Sourcepub fn take_elements(self) -> Vec<T>
pub fn take_elements(self) -> Vec<T>
Take the elements as a vec
Trait Implementations§
Source§impl<'a, Opt, T> IndentedDisplay<'a, Opt> for Hierarchy<T>
impl<'a, Opt, T> IndentedDisplay<'a, Opt> for Hierarchy<T>
Auto Trait Implementations§
impl<T> Freeze for Hierarchy<T>
impl<T> RefUnwindSafe for Hierarchy<T>where
T: RefUnwindSafe,
impl<T> Send for Hierarchy<T>where
T: Send,
impl<T> Sync for Hierarchy<T>where
T: Sync,
impl<T> Unpin for Hierarchy<T>where
T: Unpin,
impl<T> UnwindSafe for Hierarchy<T>where
T: UnwindSafe,
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