Add nextNodeBefore primitive.
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 7 Feb 2012 17:24:05 +0000 (17:24 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 7 Feb 2012 17:24:05 +0000 (17:24 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@1198 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

XMLTree.cpp
XMLTree.h

index a1eb13c..7ced902 100644 (file)
@@ -74,7 +74,7 @@ XMLTree::XMLTree( pb * const par, uint npar,  vector<string> * const TN,  TagIdM
     // creates the data structure for the tree topology\r
     Par = (bp *)umalloc(sizeof(bp));\r
     STARTTIMER();\r
-    bp_construct(Par, npar, (pb*) par, OPT_DEGREE|0);\r
+    bp_construct(Par, npar, (pb*) par, OPT_FAST_PREORDER_SELECT | OPT_DEGREE|0);\r
     STOPTIMER(Building);\r
     PRINTTIME("Building parenthesis struct", Building);\r
     STARTTIMER();\r
index 313f7ca..3b07aaf 100644 (file)
--- a/XMLTree.h
+++ b/XMLTree.h
@@ -773,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)
 {