类 HoffmanEncoder
- java.lang.Object
-
- com.github.myibu.algorithm.endode.HoffmanEncoder
-
-
方法详细资料
-
encode
public Bits encode(byte[] in_data, int in_len)
1. Sort the probability of all source symbols in a descending order. 2. Merge the last two into a new symbol, add their probabilities. 3. Repeat Step 1, 2 until only one symbol (the root) is left. 4. Code assignment: Traverse the tree from the root to each leaf node, assign 0 to the top branch and 1 to the bottom branch- 参数:
in_data- in_datain_len- in_len- 返回:
- Bits
-
decode
public byte[] decode(Bits encodedBits)
-
-