pub struct PolyTree<T> { /* private fields */ }
Expand description
A read-only poly-tree data structure.
Similar to Tree
<T>
but allows multiple root nodes.
Implementations§
Source§impl<T> PolyTree<T>
impl<T> PolyTree<T>
Sourcepub fn roots(&self) -> Children<'_, T> ⓘ
pub fn roots(&self) -> Children<'_, T> ⓘ
Returns an iterator over the root nodes of the poly-tree.
Sourcepub fn get(&self, rank: usize) -> Option<Node<'_, T>>
pub fn get(&self, rank: usize) -> Option<Node<'_, T>>
Returns the node with the specified rank
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of nodes in the poly-tree.
Because poly-trees are required to not be empty, the length will always
be at least 1
.
Sourcepub fn into_sapling(self) -> Sapling<T>
pub fn into_sapling(self) -> Sapling<T>
Turns the poly-tree back into a sapling. No nodes are removed from the tree; building the returned sapling will result in the original poly-tree.
All internal buffers are reused, making this a cheap operation. The only
cost of converting Sapling
<T>
s and PolyTree
<T>
s back and
forth is the validation that occurs during build_polytree
.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PolyTree<T>
impl<T> RefUnwindSafe for PolyTree<T>where
T: RefUnwindSafe,
impl<T> Send for PolyTree<T>where
T: Send,
impl<T> Sync for PolyTree<T>where
T: Sync,
impl<T> Unpin for PolyTree<T>where
T: Unpin,
impl<T> UnwindSafe for PolyTree<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