\r
\r
\r
-\r
static treeNode fast_sibling(bp* Par,treeNode x,TagType tag){\r
\r
if (tag == PCDATA_TAG_ID){\r
\r
}\r
\r
-static bool fast_isleaf(bp* Par,treeNode x){\r
- return (fast_inspect(Par,x+1) == CP ? true : false);\r
-}\r
+\r
\r
\r
inline uint get_field_no_power(uint *A, uint len, uint index) {\r
// TaggedChild(x,tag): returns the first child of node x tagged tag, or NULLT if there is none.\r
// Because of the balanced-parentheses representation of the tree, this operation is not supported\r
// efficiently, just iterating among the children of node x until finding the desired child.\r
+/*\r
treeNode XMLTree::TaggedChild(treeNode x, TagType tag) \r
{\r
\r
}\r
return NULLT; // no such sibling was found \r
}\r
-\r
+*/\r
treeNode XMLTree::SelectChild(treeNode x, TagIdSet *tags)\r
{\r
\r
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