//////////////////////////////////////////////////////////////////// // Scan the tree using recursive routine and set the number // of bits to represent the code //////////////////////////////////////////////////////////////////// private void BuildCodeTree ( Int32 Ptr, Int32 BitCount ) { FreqNode FN = FreqTree[Ptr]; // we are at a parent node if (FN.Code < 0) { // go to children on the left side of this node BuildCodeTree(FN.Child - 1, BitCount + 1); // go to children on the right side of this node BuildCodeTree(FN.Child, BitCount + 1); } // we are at child node else { if (BitCount > MaxUsedBitLen) { MaxUsedBitLen = BitCount; } CodeLength[FN.Code] = (Byte)BitCount; } return; }
/// <summary> /// Scan the tree using recursive routine and set the number of bits to represent the code /// </summary> /// <param name="ptr">The PTR.</param> /// <param name="bitCount">The bit count.</param> private void BuildCodeTree(int ptr, int bitCount) { FreqNode fn = _freqTree[ptr]; // we are at a parent node if (fn.Code < 0) { // go to children on the left side of this node BuildCodeTree(fn.Child - 1, bitCount + 1); // go to children on the right side of this node BuildCodeTree(fn.Child, bitCount + 1); } // we are at child node else { if (bitCount > _maxUsedBitLen) { _maxUsedBitLen = bitCount; } _codeLength[fn.Code] = (byte)bitCount; } }