public void Encode()
        {
            Dictionary <byte, int> symbolQuantityDic = createDictionary();
            var           builder      = new HuffmanCodecBuilder <byte>();
            var           tree         = builder.BuildTree(Comparer <byte> .Default, symbolQuantityDic);
            ICoder <byte> huffmanCoder = builder.GetCoder(tree);

            huffmanCoder.Encode(new StandardHuffmanCoderInput(inputReader), new HuffmanCoderOutput(coderOutputWriter));
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Standard, false, SymbolQuantityMapConverter.StandardIntToExtConvert(symbolQuantityDic, huffmanCoder.GetEncodingDictionary()));
        }
Ejemplo n.º 2
0
        public void Encode()
        {
            var symbolQuantityDic = createDictionary();
            var builder           = new HuffmanCodecBuilder <Tuple <byte, DefaultableSymbol <byte> > >();
            var tree       = builder.BuildTree(new PairComparer(), symbolQuantityDic);
            var coder      = builder.GetCoder(tree);
            var coderInput = new PairHuffmanCoderInput(inputReader);

            coder.Encode(coderInput, new HuffmanCoderOutput(coderOutputWriter));
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Block, coderInput.isSpecialSymbol, SymbolQuantityMapConverter.PairIntToExtConvert(symbolQuantityDic, coder.GetEncodingDictionary()));
        }
        public void Encode()
        {
            DefaultableSymbol <byte> previousSymbol;
            Dictionary <DefaultableSymbol <byte>, ICoder <byte> > coderDictionary = createCoderDictionary();

            coderDictionary[new DefaultableSymbol <byte>(true)].Encode(new MarkowHuffmanCoderInput(inputReader.Current), new HuffmanCoderOutput(coderOutputWriter));
            previousSymbol = new DefaultableSymbol <byte>(inputReader.Current);
            while (inputReader.MoveNext())
            {
                coderDictionary[previousSymbol].Encode(new MarkowHuffmanCoderInput(inputReader.Current), new HuffmanCoderOutput(coderOutputWriter));
                previousSymbol = new DefaultableSymbol <byte>(inputReader.Current);
            }
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Markov, true, SymbolQuantityMapConverter.MarkowIntToExtConvert(this.symbolDictionary, CreateEncodingDictionaries(coderDictionary)));
        }