X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fwt_coder_huff.cpp;fp=libcds%2Fsrc%2Fstatic_sequence%2Fwt_coder_huff.cpp;h=0000000000000000000000000000000000000000;hb=58aa6c1117e13edd366329cdcac4ba7388faed95;hp=5ba633bc58ba1c7128a45b131ad38304529eaca9;hpb=a75155efc2ed07c1907ef017360bd719a47f9c06;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_sequence/wt_coder_huff.cpp b/libcds/src/static_sequence/wt_coder_huff.cpp deleted file mode 100644 index 5ba633b..0000000 --- a/libcds/src/static_sequence/wt_coder_huff.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* wt_coder_huff.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder_huff definition - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include - -wt_coder_huff::wt_coder_huff(uint * symbs, uint n, alphabet_mapper * am) { - for(uint i=0;imap(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;iunmap(symbs[i]); -} - -wt_coder_huff::wt_coder_huff(uchar * symbs, uint n, alphabet_mapper * am) { - for(uint i=0;imap((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;iunmap((uint)symbs[i]); -} - -wt_coder_huff::wt_coder_huff() {} - -wt_coder_huff::~wt_coder_huff() { - delete hc; - delete [] buffer; -} - -bool wt_coder_huff::is_set(uint symbol, uint l) { - if(symbol!=last_symbol) { - s_len = (uint)hc->encode(symbol, buffer, (ulong)0); - last_symbol = symbol; - } - return bitget(buffer,l); -} - -bool wt_coder_huff::done(uint symbol, uint l) { - if(symbol!=last_symbol) { - s_len = (uint)hc->encode(symbol, buffer, (ulong)0); - last_symbol = symbol; - } - return l==s_len; -} - -uint wt_coder_huff::size() { - return 2*sizeof(uint)+sizeof(wt_coder_huff)+hc->size()+(hc->max_length()/W+1)*sizeof(uint); -} - -uint wt_coder_huff::save(FILE * fp) { - uint wr = WT_CODER_HUFF_HDR; - wr = fwrite(&wr,sizeof(uint),1,fp); - if(wr!=1) return 1; - if(hc->save(fp)) return 1; - //if(am->save(fp)) return 1; - return 0; -} - -wt_coder_huff * wt_coder_huff::load(FILE *fp) { - uint rd; - if(fread(&rd,sizeof(uint),1,fp)!=1) return NULL; - if(rd!=WT_CODER_HUFF_HDR) return NULL; - wt_coder_huff * ret = new wt_coder_huff(); - ret->hc = huffman_codes::load(fp); - ret->buffer = new uint[ret->hc->max_length()/W+1]; - ret->s_len = 0; ret->last_symbol = (uint)-1; - return ret; -}