X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fcoders%2Fhuffman_codes.h;fp=libcds%2Fsrc%2Fcoders%2Fhuffman_codes.h;h=a82c8dda18e633a65fb790c13e713531f00356f4;hb=a9846746dc7a55764591fcc273fd48c6049df962;hp=d421899236f8bba2d8ac2a4de16b749104ccda18;hpb=efe894650813a19a0e1408eb5807e59f037afc3b;p=SXSI%2FXMLTree.git diff --git a/libcds/src/coders/huffman_codes.h b/libcds/src/coders/huffman_codes.h index d421899..a82c8dd 100644 --- a/libcds/src/coders/huffman_codes.h +++ b/libcds/src/coders/huffman_codes.h @@ -1,3 +1,23 @@ +/* huffman_codes.h + Copyright (C) 2008, Francisco Claude, all rights reserved. + + Wrapper for huff written by Gonzalo Navarro + + 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 + +*/ #ifndef HUFFMAN_CODES_H #define HUFFMAN_CODES_H @@ -5,17 +25,33 @@ #include #include +/** Wrapper for the canonical huffman implementation of Gonzalo Navarro. + * + * @author Francisco Claude + */ class huffman_codes { public: + /** Creates the codes for the sequence seq of length n */ huffman_codes(uint * seq, uint n); ~huffman_codes(); + /** Encodes symb into stream at bit-position pos, return the ending position (bits) */ ulong encode(uint symb, uint * stream, ulong pos); + + /** decodes into symb from stream at bit-position pos, returns the new position */ ulong decode(uint * symb, uint * stream, ulong pos); + + /** Returns the maximum length of a code */ uint max_length(); + + /** Returns the size of the table */ uint size(); + + /** Saves the coder to a file */ uint save(FILE *fp); + + /** Loads a coder from a file */ static huffman_codes * load(FILE *fp); protected: