示例#1
0
        // Look up the tables in the exercise statement.
        public void ShowHuffman(DataGridView Grid, HuffmanTree Huffman)
        {
            int roundLimit = 4;

            Grid.ColumnCount          = 5;
            Grid.ColumnHeadersVisible = false;
            Grid.RowHeadersVisible    = false;

            var input = Huffman.Result.ToList();

            for (int i = 0; i < input.Count; i++)
            {
                Grid.Rows.Add();

                double probability = Math.Round(input[i].Value.Item3, roundLimit);

                Grid[0, i].Value = input[i].Key;
                Grid[1, i].Value = input[i].Value.Item1;
                Grid[2, i].Value = probability;
                Grid[3, i].Value = input[i].Value.Item2;
                Grid[4, i].Value = input[i].Value.Item2.Length;
            }
        }