X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=8dcdaec6904f8e017e064e912fa129ced60a8b57;hb=c1865639eb1a804ff9363035a2a656b64fd98b9e;hp=95546fd0644aa38c03d3239554a698255a7ab955;hpb=5480b55c9fd5bcc10f4105c7ba53b83626856b4f;p=SXSI%2FXMLTree.git 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.