Add nextNodeBefore primitive.
[SXSI/XMLTree.git] / XMLTree.h
index 676c214..3b07aaf 100644 (file)
--- a/XMLTree.h
+++ b/XMLTree.h
@@ -740,6 +740,10 @@ public:
      /** TaggedDesc(x,tag): returns the first node tagged tag with larger
     * preorder than x and within the subtree of x. Returns NULT if there
     * is none. */
+  inline treeNode TaggedNext(treeNode x, TagType tag)
+  {
+    return tagpos2node(Tags->select_next(tag,node2tagpos(x)));
+  }
   inline treeNode TaggedDescendant(treeNode x, TagType tag)
   {
 
@@ -769,6 +773,14 @@ public:
          else return NULLT;
   };
 
+  inline treeNode NextNodeBefore(treeNode x, treeNode ancestor_closing)
+  {
+    treeNode close = fast_find_close(Par, x);
+    int rank = rank_open(Par, close);
+    treeNode y = select_open(Par, rank+1);
+    return (y < ancestor_closing) ? y : NULLT;
+  };
+
 // TaggedSibling(x,tag): returns the first sibling of node x tagged tag, or NULLT if there is none.
 treeNode TaggedFollowingSibling(treeNode x, TagType tag)
 {