From e38bc834442d5369a523ba47d74865e48995ace4 Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 7 Feb 2012 17:24:05 +0000 Subject: [PATCH] Add nextNodeBefore primitive. git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@1198 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- XMLTree.cpp | 2 +- XMLTree.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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) { -- 2.17.1