return 0;
}
+///////////////////////////////////////////
+// inspect(bp *b, int s)
+// returns OP (==1) or CP (==0) at s-th bit (0 <= s < n)
+///////////////////////////////////////////
+static inline int bp_inspect(bp *b, int s)
+{
+ return bp_getbit(b->B, s);
+}
///////////////////////////////////////////
// find_close(bp *b,int s)
///////////////////////////////////////////
static inline int bp_find_close(bp *b,int s)
{
- return bp_fwd_excess(b, s, -1);
+ int s1 = s + 1;
+ if (bp_inspect(b, s1) == CP)
+ return s1;
+ else
+ return bp_fwd_excess(b, s, -1);
}
///////////////////////////////////////////
int bp_postorder_rank(bp *b,int s);
-///////////////////////////////////////////
-// inspect(bp *b, int s)
-// returns OP (==1) or CP (==0) at s-th bit (0 <= s < n)
-///////////////////////////////////////////
-static inline int bp_inspect(bp *b, int s)
-{
- return bp_getbit(b->B, s);
-}
-
static inline int bp_isleaf(bp *b, int s)
{
return (bp_inspect(b, s+1) == CP);
static inline int bp_first_child(bp *b, int s)
{
- return (bp_inspect(b, s+1) == CP) ? -1 : s+1;
+ int s1 = s + 1;
+ return bp_inspect(b, s1) ? s1 : -1;
}
{
int t;
t = bp_find_close(b, s) + 1;
- return (bp_inspect(b, t) == CP) ? -1 : t;
+ return bp_inspect(b, t) ? t : -1;
}