projects
/
SXSI
/
XMLTree.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6705d3d
)
Optimize isFirstChild
author
Kim Nguyễn
<kn@lri.fr>
Thu, 29 Mar 2012 11:59:27 +0000
(13:59 +0200)
committer
Kim Nguyễn
<kn@lri.fr>
Thu, 29 Mar 2012 11:59:27 +0000
(13:59 +0200)
XMLTree.h
patch
|
blob
|
history
diff --git
a/XMLTree.h
b/XMLTree.h
index
351db20
..
74a71e6
100644
(file)
--- a/
XMLTree.h
+++ b/
XMLTree.h
@@
-294,10
+294,15
@@
public:
bool IsChild(treeNode x, treeNode y);
/** IsFirstChild(x): returns whether node x is the first child of its parent. */
bool IsChild(treeNode x, treeNode y);
/** IsFirstChild(x): returns whether node x is the first child of its parent. */
- /*
OCAML */
+ /*
SLOW
bool IsFirstChild(treeNode x) {
return ((x != NULLT)&&(x==Root() || bp_prev_sibling(Par,x) == (treeNode)-1));
};
bool IsFirstChild(treeNode x) {
return ((x != NULLT)&&(x==Root() || bp_prev_sibling(Par,x) == (treeNode)-1));
};
+ */
+
+ bool IsFirstChild(treeNode x) {
+ return (x <= Root()) || (bp_inspect(Par,x-1) == OP);
+ }
/** NumChildren(x): number of children of node x. Constant time with the
* data structure of Sadakane. */
/** NumChildren(x): number of children of node x. Constant time with the
* data structure of Sadakane. */