pub struct Node<D, P, C> {
pub idx: NodeIdx,
pub parents: Vec<(NodeIdx, P)>,
pub children: Vec<(NodeIdx, C)>,
pub data: D,
}Fields§
§idx: NodeIdx§parents: Vec<(NodeIdx, P)>§children: Vec<(NodeIdx, C)>§data: DImplementations§
Source§impl<D, P, C> Node<D, P, C>
impl<D, P, C> Node<D, P, C>
pub fn new(idx: NodeIdx, data: D) -> Self
pub fn parents(&self) -> impl DoubleEndedIterator<Item = (NodeIdx, &P)> + '_
pub fn parent_idxs(&self) -> impl DoubleEndedIterator<Item = NodeIdx> + '_
Sourcepub fn parent_idx(&self) -> Result<NodeIdx>
pub fn parent_idx(&self) -> Result<NodeIdx>
Assuming self has exactly one parent node, return it.
Return an error if the assumption is violated.
pub fn parent_edges( &self, ) -> impl DoubleEndedIterator<Item = Edge<NodeIdx, &P>> + '_
pub fn parent_edges_mut( &mut self, ) -> impl DoubleEndedIterator<Item = Edge<NodeIdx, &mut P>> + '_
pub fn count_parents(&self) -> usize
pub fn has_parents(&self) -> bool
pub fn add_parent(&mut self, pidx: NodeIdx, pdata: P)
Sourcepub fn insert_parent(&mut self, pidx: NodeIdx, pdata: P, pos: usize)
pub fn insert_parent(&mut self, pidx: NodeIdx, pdata: P, pos: usize)
Insert (pidx, pdata) as the pos-th parent of self.
Sourcepub fn remove_parent(&mut self, parent_idx: NodeIdx) -> Result<P>
pub fn remove_parent(&mut self, parent_idx: NodeIdx) -> Result<P>
Filter out parent_idx from self.parents.
Return an error if self.parents does not contain parent_idx.
pub fn children(&self) -> impl DoubleEndedIterator<Item = (NodeIdx, &C)> + '_
pub fn child_idxs(&self) -> impl DoubleEndedIterator<Item = NodeIdx> + '_
pub fn first_child_idx(&self) -> Option<NodeIdx>
pub fn last_child_idx(&self) -> Option<NodeIdx>
pub fn nth_child_idx(&self, n: usize) -> Option<NodeIdx>
pub fn child_edges( &self, ) -> impl DoubleEndedIterator<Item = Edge<NodeIdx, &C>> + '_
pub fn count_children(&self) -> usize
pub fn has_children(&self) -> bool
pub fn add_child(&mut self, cidx: NodeIdx, cdata: C)
Sourcepub fn insert_child(&mut self, cidx: NodeIdx, cdata: C, pos: usize)
pub fn insert_child(&mut self, cidx: NodeIdx, cdata: C, pos: usize)
Insert child_idx as the pos-th child of self.
Sourcepub fn remove_child(&mut self, child_idx: NodeIdx) -> Result<C>
pub fn remove_child(&mut self, child_idx: NodeIdx) -> Result<C>
Filter out child_idx from self.children.
Return an error if self.children does not contain child_idx.
Sourcepub fn get_parent_ordinal(&self, parent_idx: NodeIdx) -> Option<usize>
pub fn get_parent_ordinal(&self, parent_idx: NodeIdx) -> Option<usize>
Assuming that parent_idx is a member of self.parents, return the
ordinal numeral
for parent_idx e.g. the leftmost parent is the zeroth parent of
self.
Return None if parent_idx is not a member of self.parents.
Sourcepub fn get_child_ordinal(&self, child_idx: NodeIdx) -> Option<usize>
pub fn get_child_ordinal(&self, child_idx: NodeIdx) -> Option<usize>
Assuming that child_idx is a member of self.children, return the
ordinal numeral
for child_idx e.g. the leftmost child is the zeroth child of
self.
Return None if child_idx is not a member of self.children.
pub fn is_root_node(&self) -> bool
pub fn is_branch_node(&self) -> bool
pub fn is_leaf_node(&self) -> bool
Trait Implementations§
Source§impl<'de, D, P, C> Deserialize<'de> for Node<D, P, C>
impl<'de, D, P, C> Deserialize<'de> for Node<D, P, C>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<D: Ord, P: Ord, C: Ord> Ord for Node<D, P, C>
impl<D: Ord, P: Ord, C: Ord> Ord for Node<D, P, C>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<D: PartialOrd, P: PartialOrd, C: PartialOrd> PartialOrd for Node<D, P, C>
impl<D: PartialOrd, P: PartialOrd, C: PartialOrd> PartialOrd for Node<D, P, C>
impl<D: Eq, P: Eq, C: Eq> Eq for Node<D, P, C>
impl<D, P, C> StructuralPartialEq for Node<D, P, C>
Auto Trait Implementations§
impl<D, P, C> Freeze for Node<D, P, C>where
D: Freeze,
impl<D, P, C> RefUnwindSafe for Node<D, P, C>
impl<D, P, C> Send for Node<D, P, C>
impl<D, P, C> Sync for Node<D, P, C>
impl<D, P, C> Unpin for Node<D, P, C>
impl<D, P, C> UnwindSafe for Node<D, P, C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more