예제 #1
0
        private void AddBitToCode(HuffmanNode node, bool isLeft)
        {
            bool bitToAdd = !isLeft;

            foreach (int symbol in node.Symbols)
            {
                if (this.Codes.ContainsKey(symbol))
                {
                    this.Codes[symbol].Insert(0, bitToAdd);
                }
                else
                {
                    this.Codes[symbol] = new List <bool> {
                        bitToAdd
                    }
                };
            }
        }
예제 #2
0
 public static int CompareNodes(HuffmanNode left, HuffmanNode right)
 {
     return(left.Count.CompareTo(right.Count));
 }