示例#1
0
        //Affiche la node, puis ses enfants
        public override String ToString()
        {
            String s = Symbol + " " + Weight + "\n";

            if (Left_son != null)
            {
                s += "      " + Left_son.ToString();
            }
            if (Right_son != null)
            {
                s += "      " + Right_son.ToString();
            }
            return(s);
        }
示例#2
0
 public void Decode(List <bool> buffer, byte[] res, int pos)
 {
     if (Symbol == 0)
     {
         if (buffer[0] == false)
         {
             buffer.RemoveAt(0);
             Left_son.Decode(buffer, res, pos);
         }
         else
         {
             buffer.RemoveAt(0);
             Right_son.Decode(buffer, res, pos);
         }
     }
     else
     {
         res[pos] = Symbol;
     }
 }
示例#3
0
 //Trouve l'encodage correspondant au noeud et à ses enfants
 public void Encode(Dictionary <bool[], byte> tabhuff, bool[] t)
 {
     if (Symbol != 0)
     {
         tabhuff.Add(t, Symbol);
     }
     else
     {
         if (Left_son != null)
         {
             bool[] tmp_left = new bool[t.Length + 1];
             t.CopyTo(tmp_left, 0);
             tmp_left[t.Length] = false;
             Left_son.Encode(tabhuff, tmp_left);
         }
         if (Right_son != null)
         {
             bool[] tmp_right = new bool[t.Length + 1];
             t.CopyTo(tmp_right, 0);
             tmp_right[t.Length] = true;
             Right_son.Encode(tabhuff, tmp_right);
         }
     }
 }