From: kim Date: Wed, 11 Mar 2009 00:28:53 +0000 (+0000) Subject: Added TaggedFollBelow X-Git-Url: http://git.nguyen.vg/gitweb/?a=commitdiff_plain;h=c1865639eb1a804ff9363035a2a656b64fd98b9e;p=SXSI%2FXMLTree.git Added TaggedFollBelow git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@243 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- diff --git a/XMLTree.cpp b/XMLTree.cpp index 95546fd..8dcdaec 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -753,6 +753,24 @@ treeNode XMLTree::TaggedFoll(treeNode x, TagType tag) else return tagpos2node(s); } +// TaggedFoll(x,tag): returns the first node tagged tag with larger preorder than x and not in +// the subtree of x. Returns NULLT if there is none. +treeNode XMLTree::TaggedFollBelow(treeNode x, TagType tag, treeNode root) + { + + int r, s; + int lim = node2tagpos(find_close(Par,root)); + if (x ==NULLT || x == Root()) + return NULLT; + + r = (int) Tags->rank(tag,find_close(Par,x)); + s = (int) Tags->select(tag, r+1); // select returns -1 in case that there is no r+1-th tag. + if (s==-1 || s >= lim) + return NULLT; + else + return tagpos2node(s); + } + // TaggedFollowingSibling(x,tag): returns the first node tagged tag with larger preorder than x and not in // the subtree of x. Returns NULLT if there is none. diff --git a/XMLTree.h b/XMLTree.h index 1f8df57..80173a4 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -232,7 +232,8 @@ public: * preorder than x and not in the subtree of x. Returns NULLT if there * is none. */ treeNode TaggedFoll(treeNode x, TagType tag); - + + treeNode TaggedFollBelow(treeNode x, TagType tag,treeNode root); /** TaggedFollowingSibling(x,tag) */ treeNode TaggedFollowingSibling(treeNode x, TagType tag);