Add NumTags method.
[SXSI/XMLTree.git] / bp.h
diff --git a/bp.h b/bp.h
index 30c841e..f109026 100644 (file)
--- a/bp.h
+++ b/bp.h
@@ -1,3 +1,6 @@
+#ifndef BP_H_
+#define BP_H_
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "darray.h"
 //#define logMB 3
 #define MB (1<<logMB)
 
-#define ETW 8  // width of excess lookup table
+#define ETW 8   // width of excess lookup table
 #define W1 2    // branching factor
 
-#ifndef min
- #define min(x,y) ((x)<(y)?(x):(y))
-#endif
-#ifndef max
- #define max(x,y) ((x)>(y)?(x):(y))
-#endif
 
 
 typedef struct {
@@ -129,7 +126,18 @@ void saveTree(bp *b, FILE *fp);
 void loadTree(bp *b, FILE *fp);
 void destroyTree(bp *b);
 
-int blog(int x);
+
+inline int blog(int x)
+{
+  int l;
+  l = 0;
+  while (x>0) {
+    x>>=1;
+    l++;
+  }
+  return l;
+}
+
 pb getpat_preorder(pb *b);
 pb getpat_leaf(pb *b);
 pb getpat_inorder(pb *b);
@@ -156,3 +164,6 @@ extern int degtbl2[(2*ETW+1)*(1<<ETW)];
 extern int childtbl[(ETW)*(1<<ETW)];
 extern int depthtbl[(2*ETW+1)*(1<<ETW)];
 extern int childtbl2[2*ETW+1][ETW][(1<<ETW)];
+
+
+#endif