예제 #1
0
 /// Parses the Huffman tree to retrieve symbol values of the
 /// provided bitset. 
 private String ParseTree(Node n, DAABitArray bitArray)
 {
     String finalString = "";
     Node temp = n;
     while (bitArray.GetCount() > 0)
     {
         while (temp.IsBranch())
         {
             if (bitArray.GetBitAsBool(0))
             {
                 temp = temp.GetRight();
                 bitArray.RemoveFirstBit();
             }
             else
             {
                 temp = temp.GetLeft();
                 bitArray.RemoveFirstBit();
             }
         }
         finalString += temp.GetSymbol();
         temp = n;
     }
     return finalString;
 }
예제 #2
0
 /// When the message is encoded, a '1' is added to the bitset,
 /// followed by a series of '0's to buffer the bitset into sections
 /// of 6 bits each (% 6). This function removes this buffer to 
 /// provide the original bitset.
 private DAABitArray RemoveBuffer(DAABitArray bitArray)
 {
     while (!bitArray.GetBitAsBool(bitArray.GetCount() -1))
     {
         bitArray.RemoveLastBit(); /// Remove '0's
     }
     bitArray.RemoveLastBit(); /// Remove '1'
     return bitArray;
 }