+// TaggedSibling(x,tag): returns the first sibling of node x tagged tag, or NULLT if there is none.\r
+treeNode XMLTree::TaggedFollSibling(treeNode x, TagType tag)\r
+{\r
+ NULLT_IF(x==NULLT);\r
+ treeNode sibling = next_sibling(Par, x); \r
+ while (sibling != NULLT) {\r
+ if (get_field(tags_fix,tags_blen,node2tagpos(sibling)) == tag) // current sibling is labeled with tag of interest\r
+ return sibling; \r
+ sibling = next_sibling(Par, sibling); // OK, let's try with the next sibling\r
+ }\r
+ return NULLT; // no such sibling was found \r
+}\r
+\r
+treeNode XMLTree::SelectChild(treeNode x, std::unordered_set<int> *tags)\r
+{\r
+ \r
+ NULLT_IF(x==NULLT || isleaf(Par,x));\r
+ int i;\r
+ treeNode child = first_child(Par, x); \r
+ TagType t = get_field(tags_fix, tags_blen, node2tagpos(child));\r
+ std::unordered_set<int>::const_iterator tagit = tags->find(t);\r
+ if (tagit != tags->end()) return child; \r
+ return SelectFollSibling(child,tags);\r
+}\r
+\r
+\r
+treeNode XMLTree::SelectFollSibling(treeNode x, std::unordered_set<int> *tags)\r
+{\r
+\r
+ NULLT_IF(x==NULLT);\r
+ int i;\r
+ TagType t;\r
+ treeNode sibling = next_sibling(Par, x);\r
+ std::unordered_set<int>::const_iterator tagit;\r
+ while (sibling != NULLT) {\r
+ t = get_field(tags_fix, tags_blen, node2tagpos(sibling));\r
+ tagit = tags->find(t);\r
+ if (tagit != tags->end()) return sibling;\r
+ sibling = next_sibling(Par, sibling);\r
+ }\r
+ return NULLT; \r
+ }\r
+\r
+\r