pub struct RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash, {
pub parents: Vec<RoseTreeNode<T>>,
pub children: Vec<RoseTreeNode<T>>,
pub value: T,
}Expand description
RoseTreeNode can start from multiple roots
Fields
parents: Vec<RoseTreeNode<T>>children: Vec<RoseTreeNode<T>>value: TImplementations
sourceimpl<T> RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T> RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
pub fn set_parents(&mut self, parents: Vec<RoseTreeNode<T>>)
pub fn set_children(&mut self, children: Vec<RoseTreeNode<T>>)
pub fn get_value(self) -> T
sourceimpl<T> RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T> RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
pub fn new(value: T) -> RoseTreeNode<T>
sourcepub fn parents_by_level(node: RoseTreeNode<T>) -> HashMap<i32, HashSet<T>>
pub fn parents_by_level(node: RoseTreeNode<T>) -> HashMap<i32, HashSet<T>>
This is a BFS problem
pub fn children_by_level(
node: RoseTreeNode<T>,
parents_by_level: &mut HashMap<i32, HashSet<T>>
) -> HashMap<i32, HashSet<T>>
sourcepub fn nodes_by_level(node: RoseTreeNode<T>) -> HashMap<i32, HashSet<T>>
pub fn nodes_by_level(node: RoseTreeNode<T>) -> HashMap<i32, HashSet<T>>
Iterate to parents and children from the given node, collecting all the relations (BFS-like) and return a hahsmap where the key is the level of the hashset nodes.
Trait Implementations
sourceimpl<T: Clone> Clone for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T: Clone> Clone for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
sourcefn clone(&self) -> RoseTreeNode<T>
fn clone(&self) -> RoseTreeNode<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<T: Debug> Debug for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T: Debug> Debug for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
sourceimpl<T: Hash> Hash for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T: Hash> Hash for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
sourceimpl<T> PartialEq<RoseTreeNode<T>> for RoseTreeNode<T> where
T: Eq + Clone + DebugTrait + Hash,
impl<T> PartialEq<RoseTreeNode<T>> for RoseTreeNode<T> where
T: Eq + Clone + DebugTrait + Hash,
impl<T: Eq> Eq for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
impl<T> StructuralEq for RoseTreeNode<T> where
T: Clone + DebugTrait + Eq + Hash,
Auto Trait Implementations
impl<T> RefUnwindSafe for RoseTreeNode<T> where
T: RefUnwindSafe,
impl<T> Send for RoseTreeNode<T> where
T: Send,
impl<T> Sync for RoseTreeNode<T> where
T: Sync,
impl<T> Unpin for RoseTreeNode<T> where
T: Unpin,
impl<T> UnwindSafe for RoseTreeNode<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more