Beispiel #1
0
 public Model()
 {
     Code          = new List <SymbolWrapper>();
     BlockCode     = new CodeWrapper();
     ShannonWeaver = new CodeWrapper();
     ShannonFano   = new CodeWrapper();
     Huffman       = new CodeWrapper();
 }
Beispiel #2
0
        private static string Find(this CodeWrapper wrapper, char symbol)
        {
            wrapper.Code.TryGetValue(symbol, out string result);

            if (string.IsNullOrWhiteSpace(result))
            {
                throw new Exception($"No result for key [{symbol}]");
            }

            return(result);
        }
Beispiel #3
0
 private static void CalculateValues(this CodeWrapper wrapper, Model model)
 {
     wrapper.CalcAverageCodeLength(model.Code);
     wrapper.CalcKraftNr();
     wrapper.CalcEffeciency(model.Entropy);
 }
Beispiel #4
0
 private static void Add(this CodeWrapper wrapper, char symbol, string code)
 {
     wrapper.Code.Add(symbol, code);
 }