From: kim Date: Tue, 7 Feb 2012 17:24:05 +0000 (+0000) Subject: Add nextNodeBefore primitive. X-Git-Url: http://git.nguyen.vg/gitweb/?p=SXSI%2FXMLTree.git;a=commitdiff_plain;h=e38bc834442d5369a523ba47d74865e48995ace4 Add nextNodeBefore primitive. git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@1198 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- diff --git a/XMLTree.cpp b/XMLTree.cpp index a1eb13c..7ced902 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -74,7 +74,7 @@ XMLTree::XMLTree( pb * const par, uint npar, vector * const TN, TagIdM // creates the data structure for the tree topology Par = (bp *)umalloc(sizeof(bp)); STARTTIMER(); - bp_construct(Par, npar, (pb*) par, OPT_DEGREE|0); + bp_construct(Par, npar, (pb*) par, OPT_FAST_PREORDER_SELECT | OPT_DEGREE|0); STOPTIMER(Building); PRINTTIME("Building parenthesis struct", Building); STARTTIMER(); diff --git a/XMLTree.h b/XMLTree.h index 313f7ca..3b07aaf 100644 --- 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) {