pub struct NodePool {
pub inner: Arc<NodePoolInner>,
}
Expand description
线程安全的节点池封装
使用 Arc
实现快速克隆,内部使用不可变数据结构保证线程安全
Fields§
§inner: Arc<NodePoolInner>
Implementations§
Source§impl NodePool
impl NodePool
Sourcepub fn contains_node(&self, id: &NodeId) -> bool
pub fn contains_node(&self, id: &NodeId) -> bool
检查节点是否存在
Sourcepub fn descendants(&self, parent_id: &NodeId) -> Vec<&Node>
pub fn descendants(&self, parent_id: &NodeId) -> Vec<&Node>
递归获取所有子节点(深度优先)
Sourcepub fn validate_hierarchy(&self) -> Result<(), PoolError>
pub fn validate_hierarchy(&self) -> Result<(), PoolError>
验证父子关系一致性
Sourcepub fn filter_nodes<P>(&self, predicate: P) -> Vec<&Arc<Node>>
pub fn filter_nodes<P>(&self, predicate: P) -> Vec<&Arc<Node>>
根据类型筛选节点
Sourcepub fn get_node_depth(&self, node_id: &NodeId) -> Option<usize>
pub fn get_node_depth(&self, node_id: &NodeId) -> Option<usize>
Sourcepub fn get_subtree_size(&self, node_id: &NodeId) -> usize
pub fn get_subtree_size(&self, node_id: &NodeId) -> usize
Sourcepub fn is_ancestor(&self, ancestor_id: &NodeId, descendant_id: &NodeId) -> bool
pub fn is_ancestor(&self, ancestor_id: &NodeId, descendant_id: &NodeId) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodePool
impl<'de> Deserialize<'de> for NodePool
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Send for NodePool
impl StructuralPartialEq for NodePool
impl Sync for NodePool
Auto Trait Implementations§
impl Freeze for NodePool
impl RefUnwindSafe for NodePool
impl Unpin for NodePool
impl UnwindSafe for NodePool
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