pub struct Tree<T> { /* private fields */ }Expand description
Vec-backed, flattened in pre-order, 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 tree_root_mut(&mut self) -> TreeMut<'_, T>
pub fn tree_root_mut(&mut self) -> TreeMut<'_, T>
Get a mutable TreeMut
This always success
sourcepub fn tree_node_mut(&mut self, id: NodeId) -> Option<TreeMut<'_, T>>
pub fn tree_node_mut(&mut self, id: NodeId) -> Option<TreeMut<'_, T>>
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 iter(&self) -> TreeIter<'_, T>ⓘNotable traits for TreeIter<'a, T>impl<'a, T: Debug> Iterator for TreeIter<'a, T> type Item = Node<'a, T>;
pub fn into_iter(&self) -> IntoIter<'_, T>
sourcepub fn as_data(&self) -> &[T]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn as_data(&self) -> &[T]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
A slice view of the internal data
sourcepub fn as_data_mut(&mut self) -> &mut [T]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn as_data_mut(&mut self) -> &mut [T]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[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>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
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>
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 moreimpl<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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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