From 3ae0cf9898485a2ec35df7d23cd274e7dea5796d Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 8 Jan 2024 16:13:19 +0800 Subject: 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. --- chain/src/atom/default.rs | 10 ++++++++++ chain/src/default.rs | 10 ++++++++++ chain/src/item/default/mod.rs | 9 +++++++++ 3 files changed, 29 insertions(+) (limited to 'chain/src') 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> for DefaultAtom { where Self: 'b; + type TupleIter<'b> = > as LabelGraph>>::TupleIter<'b> + where + Self: 'b, + DOption: 'b; + type LabelIter<'b> = > as LabelGraph>>::LabelIter<'b> where Self: 'b, @@ -246,6 +251,11 @@ impl LabelGraph> for DefaultAtom { self.nfa.find_children_with_label(node_id, label) } + #[inline] + fn tuples_of(&self, node_id: usize) -> Result, GraphError> { + self.nfa.tuples_of(node_id) + } + #[inline] fn labels_of(&self, node_id: usize) -> Result, 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 for DefaultChain { where Self: 'a; + type TupleIter<'a> = as LabelGraph>::TupleIter<'a> + where + Self: 'a, + Edge: 'a; + type LabelIter<'a> = as LabelGraph>::LabelIter<'a> where Self: 'a, @@ -348,6 +353,11 @@ impl LabelGraph for DefaultChain { self.graph.find_children_with_label(node_id, label) } + #[inline] + fn tuples_of(&self, node_id: usize) -> Result, GError> { + self.graph.tuples_of(node_id) + } + #[inline] fn labels_of(&self, node_id: usize) -> Result, 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 LabelGraph for DefaultForest { where Self: 'a; + type TupleIter<'a> = std::iter::Empty<(T, usize)> + where + Self: 'a, + T: 'a; + type LabelIter<'a> = std::iter::Empty<(&'a T, >::Iter<'a>)> where Self: 'a, @@ -163,6 +168,10 @@ impl LabelGraph for DefaultForest { unimplemented!("edges have no labels") } + fn tuples_of(&self, _node_id: usize) -> Result, GError> { + unimplemented!("edges have no labels") + } + fn labels_of(&self, _node_id: usize) -> Result, GError> { unimplemented!("edges have no labels") } -- cgit v1.2.3-18-g5258