Commit 24068248 by Hut

Fixed HuffmanCodeBuilder after update.

parent 67d038d8
package markov.huffman; package markov.huffman;
import com.tomgibara.bits.Bits; import com.tomgibara.bits.Bits;
import directory.passive.huffman.ByteHuffmanCodeBuilder;
import directory.passive.huffman.HuffmanCode;
import markov.stuff.SimpleCountMap; import markov.stuff.SimpleCountMap;
import markov.stuff.Utils; import markov.stuff.Utils;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -20,8 +22,10 @@ class ByteHuffmanCodeBuilderTest { ...@@ -20,8 +22,10 @@ class ByteHuffmanCodeBuilderTest {
countMap.count(i); countMap.count(i);
} }
} }
ByteHuffmanCodeBuilder<Integer, SimpleCountMap.MutableInt> builder = new ByteHuffmanCodeBuilder<>(); HuffmanCode<Integer, List<Boolean>> code =
HuffmanCode<Integer, List<Boolean>, Boolean, SimpleCountMap.MutableInt> code = builder.generateCode(countMap); ByteHuffmanCodeBuilder.<Integer, SimpleCountMap.MutableInt>createFactory()
.generateCode(countMap,
new SimpleCountMap.MutableInt.FrequencySupport());
List<Boolean> result = new ArrayList<>(); List<Boolean> result = new ArrayList<>();
result.addAll(printVarious(code, 6)); result.addAll(printVarious(code, 6));
result.addAll(printVarious(code, 2)); result.addAll(printVarious(code, 2));
...@@ -47,7 +51,8 @@ class ByteHuffmanCodeBuilderTest { ...@@ -47,7 +51,8 @@ class ByteHuffmanCodeBuilderTest {
// System.out.println(booleanListAsByteArrayToStirng(result)); // System.out.println(booleanListAsByteArrayToStirng(result));
} }
private List<Boolean> printVarious(HuffmanCode<Integer, List<Boolean>, Boolean, SimpleCountMap.MutableInt> code, int n) { private List<Boolean> printVarious(
HuffmanCode<Integer, List<Boolean>> code, int n) {
List<Boolean> c = code.encode(n); List<Boolean> c = code.encode(n);
System.out.println(c); System.out.println(c);
System.out.println(booleanListAsByteArrayToStirng(c)); System.out.println(booleanListAsByteArrayToStirng(c));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment