Beispiel #1
0
        public string Decode(BitArray code, out int codeLength)
        {
            var index  = 0;
            var length = BitArrayConverter.ConvertToInt(code, ref index, 32);
            var dict   = FrequencyDictionaryCoder.GetDictionary(code, ref index);

            codeLength = code.Length - index;
            return(TextDecode(code, index, dict, length));
        }
Beispiel #2
0
        private BitArray GetCode(string text, Dictionary <char, int> frequencyDictionary, out int codeLength)
        {
            var length         = BitArrayConverter.ConvertToBitArray(text.Length, 32);
            var dictionaryCode = FrequencyDictionaryCoder.GetCode(frequencyDictionary);
            var textCode       = TextCode(text, frequencyDictionary);

            codeLength = textCode.Length;

            return(BitArrayConverter.ConvertToBitArray(new List <BitArray>()
            {
                length, dictionaryCode, textCode
            }));
        }