else return NULLT;\r
} \r
*/\r
-\r
+ /*\r
treeNode XMLTree::TaggedFollowingBefore(treeNode x, TagType tag, treeNode closing)\r
{\r
\r
\r
return s;\r
} \r
-\r
+ */\r
/* Here we inline TaggedFoll to find the min globally, and only at the end\r
we check if the min is below the context node */\r
treeNode XMLTree::SelectFollowingBelow(treeNode x, TagIdSet *tags, treeNode ancestor)\r
\r
\r
TagIdSet::const_iterator tagit;\r
- for (tagit = tags->begin(); tagit != tags->end(); tagit++) {\r
+ for (tagit = tags->begin(); tagit != tags->end(); ++tagit) {\r
\r
aux = tagpos2node(Tags->select_next(*tagit, close));\r
- \r
- // The next sibling of x is guaranteed to be below ctx\r
- // and is the node with lowest preorder which is after ctx.\r
- // if we find it, we return early; \r
if (aux == NULLT) continue;\r
if ((min == NULLT) || (aux < min)) min = aux;\r
};\r
// found the smallest node in preorder which is after x.\r
// if ctx is the root node, just return what we found.\r
\r
- if (ancestor == Root()) return min;\r
- // else check whether if is in below the ctx node\r
-\r
- NULLT_IF (min == NULLT || min >= fast_find_close(Par, ancestor));\r
+ if (ancestor == Root() || min == NULLT || min < fast_find_close(Par, ancestor)) return min;\r
+ else return NULLT;\r
\r
- return min;\r
+ }\r
+\r
+treeNode XMLTree::SelectFollowingBefore(treeNode x, TagIdSet *tags, treeNode ancestor_closing)\r
+ {\r
+\r
+ NULLT_IF(x==NULLT || x==Root());\r
+\r
+ treeNode close = fast_find_close(Par,x);\r
+ treeNode ns = close+1;\r
+ if ( (fast_inspect(Par,ns) == OP) && (tags->find(Tag(ns)) != tags->end()))\r
+ return ns;\r
+\r
+ int i;\r
+ treeNode min = NULLT;\r
+ treeNode aux;\r
+ \r
+\r
+ TagIdSet::const_iterator tagit;\r
+ for (tagit = tags->begin(); tagit != tags->end(); ++tagit) {\r
+\r
+ aux = tagpos2node(Tags->select_next(*tagit, close));\r
+ if (aux == NULLT) continue;\r
+ if ((min == NULLT) || (aux < min)) min = aux;\r
+ };\r
+ \r
+ // found the smallest node in preorder which is after x.\r
+ // if ctx is the root node, just return what we found.\r
+\r
+ if (ancestor_closing == Root() || min == NULLT || min < ancestor_closing) return min;\r
+ else return NULLT;\r
\r
}\r
+\r
+/*\r
treeNode XMLTree::SelectFollowingBefore(treeNode x, TagIdSet *tags, treeNode closing)\r
{\r
\r
return min;\r
\r
}\r
-\r
+*/\r
\r
// TaggedAncestor(x, tag): returns the closest ancestor of x tagged tag. Return\r
// NULLT is there is none.\r