Пример #1
0
        //huff 1
        public static Node ReadFileAndBuildTree(BinaryReader Reader)
        {
            //create HuffmanReader, that is going to count occurences of bytes in input file
            HuffmanReader HuffReader = new HuffmanReader(Reader);
            bool          NotEmpty   = HuffReader.ReadFileUsingBuffer();
            //Build Huffman tree
            TreeBuilder Builder = new TreeBuilder(HuffReader.ProvideSymbolsWihtWeights());
            Node        Root    = Builder.BuildHuffTree();

            return(Root);
        }
Пример #2
0
        /// <summary>
        /// Reads file, creates Huffman tree according its content and writes it to binary writer in specified binary representation
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="writer"></param>
        /// <returns>Root of Huffman tree created</returns>
        internal static Node GenTree(BinaryReader reader, BinaryWriter writer)
        {
            HuffmanReader HuffReader = new HuffmanReader(reader);
            bool          NotEmpty   = HuffReader.ReadFileUsingBuffer();
            //Build Huffman tree
            TreeBuilder Builder = new TreeBuilder(HuffReader.ProvideSymbolsWihtWeights());
            Node        Root    = Builder.BuildHuffTree();

            TreePrinter.PrintTreeBinary(Root, writer);
            writer.Flush();
            return(Root);
        }