pub struct Tree<T> { /* private fields */ }Expand description
Vec-backed, flattened, Tree.
Always contains at least a root node.
Implementations
sourceimpl<T: Debug> Tree<T>
impl<T: Debug> Tree<T>
sourcepub fn with_capacity(root: T, capacity: usize) -> Self
pub fn with_capacity(root: T, capacity: usize) -> Self
Create a new Tree with the specified value & set the capacity of the internal vectors
sourcepub fn push_with_level(
&mut self,
data: T,
level: usize,
parent: NodeId
) -> NodeId
pub fn push_with_level(
&mut self,
data: T,
level: usize,
parent: NodeId
) -> NodeId
Push a node into the tree
#WARNING
This assumes you are pushing in pre-order!
sourcepub fn root_mut(&mut self) -> NodeMut<'_, T>
pub fn root_mut(&mut self) -> NodeMut<'_, T>
Get a mutable NodeMut
This always success
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn into_iter(&self) -> IntoIter<'_, T>
sourcepub fn as_data(&self) -> &[T]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_data(&self) -> &[T]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
A slice view of the internal data
sourcepub fn as_parents(&self) -> &[usize]
pub fn as_parents(&self) -> &[usize]
A slice view of the internal parents
Trait Implementations
sourceimpl<'a, T: Debug> IntoIterator for &'a Tree<T>
impl<'a, T: Debug> IntoIterator for &'a Tree<T>
sourceimpl<T: Ord> Ord for Tree<T>
impl<T: Ord> Ord for Tree<T>
sourceimpl<T: PartialOrd> PartialOrd<Tree<T>> for Tree<T>
impl<T: PartialOrd> PartialOrd<Tree<T>> for Tree<T>
sourcefn partial_cmp(&self, other: &Tree<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Tree<T>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl<T: Eq> Eq for Tree<T>
impl<T> StructuralEq for Tree<T>
impl<T> StructuralPartialEq for Tree<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Tree<T> where
T: RefUnwindSafe,
impl<T> Send for Tree<T> where
T: Send,
impl<T> Sync for Tree<T> where
T: Sync,
impl<T> Unpin for Tree<T> where
T: Unpin,
impl<T> UnwindSafe for Tree<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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more