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) -> &String
pub fn get_inner(&self) -> &Arc<Tree>
pub fn get_parent_node(&self, id: &String) -> Option<Arc<Node>>
Sourcepub fn contains_node(&self, id: &String) -> bool
pub fn contains_node(&self, id: &String) -> bool
检查节点是否存在
pub fn for_each<F>(&self, id: &String, f: F)
Sourcepub fn validate_hierarchy(&self) -> Result<(), Error>
pub fn validate_hierarchy(&self) -> Result<(), Error>
验证父子关系一致性
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: &String) -> Option<usize>
pub fn get_node_depth(&self, node_id: &String) -> Option<usize>
Sourcepub fn get_node_path(&self, node_id: &String) -> Vec<String>
pub fn get_node_path(&self, node_id: &String) -> Vec<String>
Sourcepub fn get_left_siblings(&self, node_id: &String) -> Vec<String>
pub fn get_left_siblings(&self, node_id: &String) -> Vec<String>
获取左边的所有节点 根据下标
Sourcepub fn get_right_siblings(&self, node_id: &String) -> Vec<String>
pub fn get_right_siblings(&self, node_id: &String) -> Vec<String>
获取右边边的所有节点 根据下标
Sourcepub fn get_all_siblings(&self, node_id: &String) -> Vec<String>
pub fn get_all_siblings(&self, node_id: &String) -> Vec<String>
Sourcepub fn get_subtree_size(&self, node_id: &String) -> usize
pub fn get_subtree_size(&self, node_id: &String) -> usize
Sourcepub fn is_ancestor(&self, ancestor_id: &String, descendant_id: &String) -> bool
pub fn is_ancestor(&self, ancestor_id: &String, descendant_id: &String) -> bool
Sourcepub fn get_lowest_common_ancestor(
&self,
node1_id: &String,
node2_id: &String,
) -> Option<String>
pub fn get_lowest_common_ancestor( &self, node1_id: &String, node2_id: &String, ) -> Option<String>
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<NodePool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodePool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for NodePool
impl Serialize for NodePool
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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