pub struct NodePool { /* private fields */ }
Expand description
线程安全的节点池封装
使用 Arc
实现快速克隆,内部使用不可变数据结构保证线程安全
Implementations§
Source§impl NodePool
impl NodePool
pub fn new(inner: Arc<Tree>) -> Arc<NodePool>
pub fn root(&self) -> Arc<Node>
pub fn root_id(&self) -> &NodeId
pub fn get_inner(&self) -> &Arc<Tree>
pub fn get_parent_node(&self, id: &NodeId) -> Option<Arc<Node>>
Sourcepub fn contains_node(&self, id: &NodeId) -> bool
pub fn contains_node(&self, id: &NodeId) -> bool
检查节点是否存在
pub fn for_each<F>(&self, id: &NodeId, f: F)
Sourcepub fn validate_hierarchy(&self) -> PoolResult<()>
pub fn validate_hierarchy(&self) -> PoolResult<()>
验证父子关系一致性
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
Sourcepub fn get_lowest_common_ancestor(
&self,
node1_id: &NodeId,
node2_id: &NodeId,
) -> Option<NodeId>
pub fn get_lowest_common_ancestor( &self, node1_id: &NodeId, node2_id: &NodeId, ) -> Option<NodeId>
Sourcepub fn parallel_query<P>(&self, predicate: P) -> Vec<Arc<Node>>
pub fn parallel_query<P>(&self, predicate: P) -> Vec<Arc<Node>>
Sourcepub fn parallel_batch_query<'a, P>(
&'a self,
batch_size: usize,
predicate: P,
) -> Vec<Arc<Node>>
pub fn parallel_batch_query<'a, P>( &'a self, batch_size: usize, predicate: P, ) -> Vec<Arc<Node>>
Sourcepub fn parallel_query_map<'a, P, T, F>(
&'a self,
predicate: P,
transform: F,
) -> Vec<T>
pub fn parallel_query_map<'a, P, T, F>( &'a self, predicate: P, transform: F, ) -> Vec<T>
Source§impl NodePool
impl NodePool
Sourcepub fn optimized_query(&self, config: QueryCacheConfig) -> OptimizedQueryEngine
pub fn optimized_query(&self, config: QueryCacheConfig) -> OptimizedQueryEngine
创建优化查询引擎(带缓存)
Source§impl NodePool
impl NodePool
Sourcepub fn lazy_query(&self, config: LazyQueryConfig) -> LazyQueryEngine
pub fn lazy_query(&self, config: LazyQueryConfig) -> LazyQueryEngine
创建懒加载查询引擎
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more