summaryrefslogtreecommitdiff
path: root/chain/src/archive.txt
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/archive.txt')
-rw-r--r--chain/src/archive.txt47
1 files changed, 47 insertions, 0 deletions
diff --git a/chain/src/archive.txt b/chain/src/archive.txt
index 030ccba..7bd6f31 100644
--- a/chain/src/archive.txt
+++ b/chain/src/archive.txt
@@ -493,3 +493,50 @@
// PaVi::Empty => Ok(self.root().ok_or(Error::IndexOutOfBounds(0, 0))?),
// }
// }
+
+// /// Find the last child of the given node whose start and end
+// /// positions contain the given position. If no such child is
+// /// found, return `Ok(None)`.
+// ///
+// /// The returned tuple is of the form (child, index), where
+// /// `child` is the index of the child node in question, and
+// /// `index` means that the child is the `index`-th child of the
+// /// node.
+// #[allow(dead_code)]
+// pub(crate) fn position_search(
+// &self,
+// node: usize,
+// pos: usize,
+// ) -> Result<Option<(usize, usize)>, Error> {
+// fn range_contains(label: GrammarLabel, pos: usize) -> bool {
+// let start = label.start();
+//
+// if let Some(end) = label.end() {
+// (start..end).contains(&pos)
+// } else {
+// (start..).contains(&pos)
+// }
+// }
+//
+// let node_label = self
+// .vertex_label(node)?
+// .ok_or(Error::NodeNoLabel(node))?
+// .label();
+//
+// if !range_contains(node_label, pos) {
+// return Ok(None);
+// }
+//
+// for (index, child) in self.children_of(node)?.enumerate().rev() {
+// let child_label = self
+// .vertex_label(child)?
+// .ok_or(Error::NodeNoLabel(child))?
+// .label();
+//
+// if range_contains(child_label, pos) {
+// return Ok(Some((child, index)));
+// }
+// }
+//
+// Ok(None)
+// }