Added support for char arrays
[SXSI/XMLTree.git] / libcds / src / static_sequence / wt_coder_binary.cpp
index cdbac13..e9f37dc 100644 (file)
@@ -28,6 +28,13 @@ wt_coder_binary::wt_coder_binary(uint * seq, uint n, alphabet_mapper * am) {
   h=bits(max_v);
 }
 
+wt_coder_binary::wt_coder_binary(uchar * seq, uint n, alphabet_mapper * am) {
+       uint max_v = 0;
+  for(uint i=0;i<n;i++)
+      max_v = max(am->map((uint)seq[i]),max_v);
+  h=bits(max_v);
+}
+
 wt_coder_binary::wt_coder_binary() {}
 
 wt_coder_binary::~wt_coder_binary() {}
@@ -38,7 +45,7 @@ bool wt_coder_binary::is_set(uint symbol, uint l) {
 }
 
 bool wt_coder_binary::done(uint symbol, uint l) {
-       if(l==h-1) return true;
+       if(l==h) return true;
        return false;
 }