示例#1
0
 public HuffmanNode(HuffmanNode a, HuffmanNode b)
 {
     this.Value = a.Value + b.Value;
     this.Weight = a.Weight + b.Weight;
     this.Left = a;
     this.Right = b;
     this.IsLeaf = false;
 }
示例#2
0
        private HuffmanNode BuildTree()
        {
            while (this.Symbols.Count > 1)
            {
                var a = this.Symbols.Poll();
                var b = this.Symbols.Poll();
                var c = new HuffmanNode(a, b);
                this.Symbols.Add(c);
            }

            return this.Symbols.Poll();
        }