Struct im_pathtree::PathTree
source · pub struct PathTree<T>where
T: PathTreeTypes,{ /* private fields */ }
Expand description
Cheaply clonable path tree structure.
Could be shared safely between multiple threads.
Implementations§
source§impl<T: PathTreeTypes> PathTree<T>
impl<T: PathTreeTypes> PathTree<T>
pub fn root_node_id(&self) -> NodeId
pub fn root_node(&self) -> &Arc<TreeNode<T>>
pub fn contains_node(&self, id: NodeId) -> bool
pub fn lookup_node(&self, id: NodeId) -> Option<&Arc<TreeNode<T>>>
pub fn find_node(&self, path: &T::RootPath) -> Option<&Arc<TreeNode<T>>>
sourcepub fn insert_or_update_node_value(
&mut self,
path: &T::RootPath,
new_value: NodeValue<T>,
new_inner_value: impl FnMut() -> T::InnerValue
) -> Result<ParentChildTreeNode<T>, InsertOrUpdateNodeValueError<T>>
pub fn insert_or_update_node_value( &mut self, path: &T::RootPath, new_value: NodeValue<T>, new_inner_value: impl FnMut() -> T::InnerValue ) -> Result<ParentChildTreeNode<T>, InsertOrUpdateNodeValueError<T>>
Insert or update a node in the tree.
All missing parent nodes are created recursively and initialized with the inner default value.
Returns the parent node and the inserted/updated child node. Both require updating the parent node as well.
In case of an error, the new value is returned back to the caller.
sourcepub fn remove_subtree(&mut self, node_id: NodeId) -> Option<RemovedSubTree<T>>
pub fn remove_subtree(&mut self, node_id: NodeId) -> Option<RemovedSubTree<T>>
Remove a node and its children from the tree.
Removes the entire subtree rooted at the given node.
The root node cannot be removed.
Returns the ID of the parent node and the IDs of the removed nodes.
pub fn node_count(&self) -> usize
pub fn count_child_nodes_recursively( &self, parent_node_id: NodeId ) -> Option<usize>
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for PathTree<T>where T: RefUnwindSafe, <T as PathTreeTypes>::InnerValue: RefUnwindSafe, <T as PathTreeTypes>::LeafValue: RefUnwindSafe, <T as PathTreeTypes>::PathSegment: RefUnwindSafe,
impl<T> Send for PathTree<T>where T: Send, <T as PathTreeTypes>::InnerValue: Send + Sync, <T as PathTreeTypes>::LeafValue: Send + Sync, <T as PathTreeTypes>::PathSegment: Send + Sync,
impl<T> Sync for PathTree<T>where T: Sync, <T as PathTreeTypes>::InnerValue: Send + Sync, <T as PathTreeTypes>::LeafValue: Send + Sync, <T as PathTreeTypes>::PathSegment: Send + Sync,
impl<T> Unpin for PathTree<T>where T: Unpin,
impl<T> UnwindSafe for PathTree<T>where T: UnwindSafe, <T as PathTreeTypes>::InnerValue: RefUnwindSafe, <T as PathTreeTypes>::LeafValue: RefUnwindSafe, <T as PathTreeTypes>::PathSegment: RefUnwindSafe,
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