Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void compress(ibstream& infile, obstream& outfile) {
- Map<ext_char, int> frequencies = getFrequencyTable(infile);
- Node* tree = buildEncodingTree(frequencies);
- writeFileHeader(outfile, frequencies);
- infile.rewind();
- encodeFile(infile, tree, outfile);
- freeTree(tree);
- }
- /* Function: decompress
- * Usage: decompress(infile, outfile);
- * --------------------------------------------------------
- * Main entry point for the Huffman decompressor.
- * Decompresses the file whose contents are specified by the
- * input ibstream, then writes the decompressed version of
- * the file to the stream specified by outfile. Your final
- * task in this assignment will be to combine all of the
- * previous functions together to implement this function,
- * which should not require much logic of its own and should
- * primarily be glue code.
- */
- void decompress(ibstream& infile, ostream& outfile) {
- Map<ext_char, int> frequenceTable = readFileHeader(infile);
- Node* tree = buildEncodingTree(frequenceTable);
- decodeFile(infile, tree, outfile);
- freeTree(tree);
- }
Advertisement
Add Comment
Please, Sign In to add comment