return (Par->B[j] >> (D-1-l)) & 1;\r
}\r
\r
+static bool fast_isleaf(bp* Par,treeNode x){\r
+ return (fast_inspect(Par, x+1) == CP);\r
+}\r
+\r
static treeNode fast_first_child(bp *Par, treeNode x)\r
{\r
x = x+1;\r
* NULLT if there is none. Because of the balanced-parentheses representation \r
* of the tree, this operation is not supported efficiently, just iterating \r
* among the children of node x until finding the desired child. */\r
- treeNode TaggedChild(treeNode x, TagType tag);\r
+\r
\r
treeNode SelectChild(treeNode x, TagIdSet * tags);\r
\r
/** TaggedFollowingSibling(x,tag): returns the first sibling of node x tagged tag, or \r
* NULLT if there is none. */\r
- treeNode TaggedFollowingSibling(treeNode x, TagType tag);\r
\r
treeNode SelectFollowingSibling(treeNode x, TagIdSet * tags);\r
\r
else return NULLT;\r
};\r
\r
+// TaggedSibling(x,tag): returns the first sibling of node x tagged tag, or NULLT if there is none.\r
+treeNode TaggedFollowingSibling(treeNode x, TagType tag)\r
+{\r
+ NULLT_IF(x==NULLT);\r
+ treeNode sibling = x;\r
+ TagType ctag;\r
+ while ((sibling = fast_next_sibling(Par, sibling)) != NULLT) {\r
+ ctag = Tag(sibling);\r
+ if (ctag == tag) return sibling; \r
+ }\r
+ return NULLT; \r
};\r
\r
+treeNode TaggedChild(treeNode x, TagType tag) \r
+{\r
+ \r
+ NULLT_IF(x==NULLT || fast_isleaf(Par,x));\r
+ treeNode child; \r
+ child = fast_first_child(Par, x);\r
+\r
+ if (Tag(child) == tag)\r
+ return child;\r
+ else\r
+ return TaggedFollowingSibling(child, tag);\r
+};\r
\r
\r
+};\r
+\r
\r
#endif\r
\r