aboutsummaryrefslogtreecommitdiff
path: root/chain
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2024-01-08 16:13:19 +0800
committerJSDurand <mmemmew@gmail.com>2024-01-08 16:13:19 +0800
commit3ae0cf9898485a2ec35df7d23cd274e7dea5796d (patch)
tree35acbd1223288eb6f62ab281b57845c0ce2ed1c5 /chain
parent55f7068e91182dfe458fad41c3251388ea461569 (diff)
a commit before the forst query
I think the main functionalities are already there, but the lack of querying capabilities makes this not very useful at the moment. This commit is right before an attempt to add this missing piece.
Diffstat (limited to 'chain')
-rw-r--r--chain/src/atom/default.rs10
-rw-r--r--chain/src/default.rs10
-rw-r--r--chain/src/item/default/mod.rs9
3 files changed, 29 insertions, 0 deletions
diff --git a/chain/src/atom/default.rs b/chain/src/atom/default.rs
index df61b6f..c6289f1 100644
--- a/chain/src/atom/default.rs
+++ b/chain/src/atom/default.rs
@@ -213,6 +213,11 @@ impl LabelGraph<LabelType<TNT>> for DefaultAtom {
where
Self: 'b;
+ type TupleIter<'b> = <DefaultNFA<LabelType<TNT>> as LabelGraph<LabelType<TNT>>>::TupleIter<'b>
+ where
+ Self: 'b,
+ DOption<TNT>: 'b;
+
type LabelIter<'b> = <DefaultNFA<LabelType<TNT>> as LabelGraph<LabelType<TNT>>>::LabelIter<'b>
where
Self: 'b,
@@ -247,6 +252,11 @@ impl LabelGraph<LabelType<TNT>> for DefaultAtom {
}
#[inline]
+ fn tuples_of(&self, node_id: usize) -> Result<Self::TupleIter<'_>, GraphError> {
+ self.nfa.tuples_of(node_id)
+ }
+
+ #[inline]
fn labels_of(&self, node_id: usize) -> Result<Self::LabelIter<'_>, GraphError> {
self.nfa.labels_of(node_id)
}
diff --git a/chain/src/default.rs b/chain/src/default.rs
index 85e3c8f..042f84e 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -324,6 +324,11 @@ impl LabelGraph<Edge> for DefaultChain {
where
Self: 'a;
+ type TupleIter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::TupleIter<'a>
+ where
+ Self: 'a,
+ Edge: 'a;
+
type LabelIter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::LabelIter<'a>
where
Self: 'a,
@@ -349,6 +354,11 @@ impl LabelGraph<Edge> for DefaultChain {
}
#[inline]
+ fn tuples_of(&self, node_id: usize) -> Result<Self::TupleIter<'_>, GError> {
+ self.graph.tuples_of(node_id)
+ }
+
+ #[inline]
fn labels_of(&self, node_id: usize) -> Result<Self::LabelIter<'_>, GError> {
self.graph.labels_of(node_id)
}
diff --git a/chain/src/item/default/mod.rs b/chain/src/item/default/mod.rs
index 01e463e..f532805 100644
--- a/chain/src/item/default/mod.rs
+++ b/chain/src/item/default/mod.rs
@@ -127,6 +127,11 @@ impl<T: GraphLabel> LabelGraph<T> for DefaultForest<T> {
where
Self: 'a;
+ type TupleIter<'a> = std::iter::Empty<(T, usize)>
+ where
+ Self: 'a,
+ T: 'a;
+
type LabelIter<'a> = std::iter::Empty<(&'a T, <Self as LabelGraph<T>>::Iter<'a>)>
where
Self: 'a,
@@ -163,6 +168,10 @@ impl<T: GraphLabel> LabelGraph<T> for DefaultForest<T> {
unimplemented!("edges have no labels")
}
+ fn tuples_of(&self, _node_id: usize) -> Result<Self::TupleIter<'_>, GError> {
+ unimplemented!("edges have no labels")
+ }
+
fn labels_of(&self, _node_id: usize) -> Result<Self::LabelIter<'_>, GError> {
unimplemented!("edges have no labels")
}