X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=bd728af5d665e695733364fc0783436b4f072ea2;hb=5db16dd3e0bf609bc0fa84ee7d067f6bbc58013e;hp=249143cfbe456ffc8d78d10262f82167baa773dd;hpb=63a9066c6cdd10751ba5e9142fc3341f50392688;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index 249143c..bd728af 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -566,13 +566,14 @@ treeNode XMLTree::TaggedDesc(treeNode x, TagType tag) exit(1); } - int r, s; + //int r, s; treeNode y; if (isleaf(Par,x)) return NULLT; - r = (int) Tags->rank(tag, node2tagpos(x)); - s = (int) Tags->select(tag, r+1); + int s = (int) Tags->select_next(tag,node2tagpos(x)); + /*r = (int) Tags->rank(tag, node2tagpos(x)); + s = (int) Tags->select(tag, r+1);*/ if (s == -1) return NULLT; // there is no such node y = tagpos2node(s); // transforms the tag position into a node position if (!is_ancestor(Par, x, y)) return NULLT; // the next node tagged tag (in preorder) is not within the subtree of x. @@ -659,14 +660,15 @@ treeNode XMLTree::TaggedDescOrFollOnly(treeNode x,TagType *folltags, unsigned in { treeNode res,y,lim; - int r,s; + //int r,s; lim = find_close(Par,root); res=NULLT; for (unsigned int i = 0; i < ftlen; i ++ ) { - r = (int) Tags->rank(folltags[i], node2tagpos(x)); - s = (int) Tags->select(folltags[i], r+1); + int s = (int) Tags->select_next(folltags[i],node2tagpos(x)); + /*r = (int) Tags->rank(folltags[i], node2tagpos(x)); + s = (int) Tags->select(folltags[i], r+1);*/ if (s == -1) y = NULLT; // there is no such node else { @@ -762,12 +764,13 @@ treeNode XMLTree::TaggedFoll(treeNode x, TagType tag) exit(1); } - int r, s; + //int r, s; 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. + + int s = (int) Tags->select_next(tag,find_close(Par,x)); + /*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) return NULLT; else return tagpos2node(s); } @@ -777,17 +780,15 @@ treeNode XMLTree::TaggedFoll(treeNode x, TagType tag) 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); + if (x == NULLT || x == Root()) return NULLT; + treeNode s = (treeNode) Tags->select_next(tag,find_close(Par,x)); + /*int r = (int) Tags->rank(tag, find_close(Par, x)); + int s = (int) Tags->select(tag, r+1); */ + if (root == Root()) + return s; + + if (s == NULLT || s >= find_close(Par,root)) return NULLT; + return s; } @@ -800,14 +801,15 @@ treeNode XMLTree::TaggedFollowingSibling(treeNode x, TagType tag) exit(1); } - int r, s; + //int r, s; treeNode ns = next_sibling(Par,x); if (x == NULLT || x == Root() || ns == -1) return NULLT; - r = (int) Tags->rank(tag, node2tagpos(ns)-1); - s = (int) Tags->select(tag, r+1); // select returns -1 in case that there is no r+1-th tag. + int s = (int) Tags->select_next(tag,node2tagpos(ns)-1); + /*r = (int) Tags->rank(tag, node2tagpos(ns)-1); + s = (int) Tags->select(tag, r+1); // select returns -1 in case that there is no r+1-th tag.*/ if (s==-1) return NULLT; else return tagpos2node(s); }