Adding support for building wavelet trees using uchar arrays
[SXSI/XMLTree.git] / libcds / src / static_sequence / wt_coder_huff.cpp
index cf831dc..5ba633b 100644 (file)
@@ -31,6 +31,16 @@ wt_coder_huff::wt_coder_huff(uint * symbs, uint n, alphabet_mapper * am) {
     symbs[i] = am->unmap(symbs[i]);
 }
 
+wt_coder_huff::wt_coder_huff(uchar * symbs, uint n, alphabet_mapper * am) {
+  for(uint i=0;i<n;i++)
+    symbs[i] = (uchar)am->map((uint)symbs[i]);
+       hc = new huffman_codes(symbs, n);
+  buffer = new uint[hc->max_length()/W+1]; 
+  s_len = 0; last_symbol = (uint)-1;
+  for(uint i=0;i<n;i++)
+    symbs[i] = (uchar)am->unmap((uint)symbs[i]);
+}
+
 wt_coder_huff::wt_coder_huff() {}
 
 wt_coder_huff::~wt_coder_huff() {