private void ReduceHuffmanNodes(List <HuffmanNode> nodeList) { while (nodeList.Count > 1) { HuffmanNode FirstNode = nodeList[0]; nodeList.RemoveAt(0); HuffmanNode SecondNode = nodeList[0]; nodeList.RemoveAt(0); nodeList.Add(new HuffmanNode(FirstNode, SecondNode)); nodeList.Sort(); } }
private void BuildHuffmanTree(string Code, HuffmanNode Node) { if (Node == null) { return; } if (Node.LeftChild == null && Node.RightChild == null) { Node.Code = Code; m_EncodingDictionary.Add(Node.Character, Node.Code); return; } BuildHuffmanTree(Code + "0", Node.LeftChild); BuildHuffmanTree(Code + "1", Node.RightChild); }