pub struct Node<T> { /* private fields */ }
Expand description
A reference to the tree node.
It has an Id, and the reference-counted data.
Most of the functions will block until there are no
more writers, holding the RwLock
.
There may be more than one reader to the data, though.
Implementations§
Source§impl<T> Node<T>
impl<T> Node<T>
Sourcepub fn read<'a>(&'a self) -> impl Deref<Target = T> + 'a
pub fn read<'a>(&'a self) -> impl Deref<Target = T> + 'a
Returns a handle, dereferencing to the node data.
This function will block until there are no more writers.
Sourcepub fn write<'a>(&'a self) -> impl DerefMut<Target = T> + 'a
pub fn write<'a>(&'a self) -> impl DerefMut<Target = T> + 'a
Returns a mutable handle, dereferencing to the node data.
This function will block until there are no more writers and readers.
Sourcepub fn first_child(&self, arena: &NodeArena<T>) -> Option<Node<T>>
pub fn first_child(&self, arena: &NodeArena<T>) -> Option<Node<T>>
Returns node’s first child, if any.
Sourcepub fn last_child(&self, arena: &NodeArena<T>) -> Option<Node<T>>
pub fn last_child(&self, arena: &NodeArena<T>) -> Option<Node<T>>
Returns node’s last child, if any.
Sourcepub fn next_sibling(&self, arena: &NodeArena<T>) -> Option<Node<T>>
pub fn next_sibling(&self, arena: &NodeArena<T>) -> Option<Node<T>>
Returns node’s next sibling, if any.
Sourcepub fn prev_sibling(&self, arena: &NodeArena<T>) -> Option<Node<T>>
pub fn prev_sibling(&self, arena: &NodeArena<T>) -> Option<Node<T>>
Returns node’s previous sibling, if any.
Sourcepub fn children<'a>(&self, arena: &'a NodeArena<T>) -> Children<'a, T> ⓘ
pub fn children<'a>(&self, arena: &'a NodeArena<T>) -> Children<'a, T> ⓘ
Returns an iterator over node’s children.
Sourcepub fn ancestors<'a>(&self, arena: &'a NodeArena<T>) -> Ancestors<'a, T> ⓘ
pub fn ancestors<'a>(&self, arena: &'a NodeArena<T>) -> Ancestors<'a, T> ⓘ
Returns an iterator over node’s ancestors.
Sourcepub fn siblings<'a>(&self, arena: &'a NodeArena<T>) -> Siblings<'a, T> ⓘ
pub fn siblings<'a>(&self, arena: &'a NodeArena<T>) -> Siblings<'a, T> ⓘ
Returns an iterator over node’s ancestors, including itself.
Sourcepub fn depth_first_traverse<'a>(
&'a self,
arena: &'a NodeArena<T>,
) -> DFTraverse<'a, T> ⓘ
pub fn depth_first_traverse<'a>( &'a self, arena: &'a NodeArena<T>, ) -> DFTraverse<'a, T> ⓘ
Returns an iterator over node’s descendants, including itself, in NLR depth-first order.
Sourcepub fn detach(&self, arena: &NodeArena<T>)
pub fn detach(&self, arena: &NodeArena<T>)
Detachs a node from it’s parent.
If node does not have a parent, does nothing.
Sourcepub fn append(&self, node: &Node<T>, arena: &NodeArena<T>)
pub fn append(&self, node: &Node<T>, arena: &NodeArena<T>)
Appends a new child to node, e.g. after the existing children.
If the parent node did not have any children before, this operation is the same as prepend.