pub struct Tree<T> { /* private fields */ }
Implementations§
Source§impl<T> Tree<T>
impl<T> Tree<T>
Sourcepub fn make_child(
&mut self,
child: &NodeId,
parent: &NodeId,
) -> Result<(), Error>
pub fn make_child( &mut self, child: &NodeId, parent: &NodeId, ) -> Result<(), Error>
Make the child
nodes as the last child of the parent
node.
§Errors
- Fails of the same
NodeId
is passed - TODO: Fail if the child node is parent of the parent node.
Sourcepub fn make_prev_siblings(
&mut self,
node: &NodeId,
sibling: &NodeId,
) -> Result<(), Error>
pub fn make_prev_siblings( &mut self, node: &NodeId, sibling: &NodeId, ) -> Result<(), Error>
Make the node
as the previous sibling of sibling
§Errors
- Fails of the same
NodeId
is passed - TODO: Fail if the child node is parent of the parent node.
Source§impl<T> Tree<T>
impl<T> Tree<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new tree with a specific parameter.
Sourcepub fn create_node(&mut self, value: T) -> NodeId
pub fn create_node(&mut self, value: T) -> NodeId
Add a node to the tree, without relations with the other nodes.
pub fn first_node_id(&self) -> Option<NodeId>
pub fn last_node_id(&self) -> Option<NodeId>
Sourcepub fn append_child(&mut self, value: T) -> NodeId
pub fn append_child(&mut self, value: T) -> NodeId
Appends the value to the last element of the three as its child. If None creates a new root.
Sourcepub fn append_sibling(&mut self, value: T) -> NodeId
pub fn append_sibling(&mut self, value: T) -> NodeId
Appends the value to the last element of the three as its sibling. If None creates a new root.
Trait Implementations§
Source§impl<'a, T> IntoIterator for &'a Tree<T>
impl<'a, T> IntoIterator for &'a Tree<T>
Auto Trait Implementations§
impl<T> Freeze for Tree<T>
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§
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