예제 #1
0
 /**
  * Creates binary tree from the ByteData binary coded labels.
  *
  * @param byteDatas     ByteDatas in the array
  */
 public void createBinaryTreeFromBinaryCodedCodes(ByteData[] byteDatas)
 {
     this.root = new ByteData((byte)0);
     for (int i = 0; i < 256; i++)
     {
         if (byteDatas[i].getCompressedLength() > 0)
         {
             ByteData current    = this.root;
             int      length     = (byteDatas[i].getCompressedLength() & 0xFF);
             long     compressed = byteDatas[i].getCompressedChar();
             for (int k = length - 1; k >= 0; k--)
             {
                 current = createLeafForTheCharacter(compressed, k, current);
             }
             byteDatas[i].setParent(current.getParent());
             if (current.getParent().getLeftChild() == current)
             {
                 byteDatas[i].getParent().setLeftChild(byteDatas[i]);
             }
             else
             {
                 byteDatas[i].getParent().setRightChild(byteDatas[i]);
             }
         }
     }
 }