forked from benaich/JavaDataStructures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeTree.java
More file actions
26 lines (19 loc) · 698 Bytes
/
CodeTree.java
File metadata and controls
26 lines (19 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package HuffmanFunctionalProgramming;
import List.ListModule;
import List.ListModule.List;
public interface CodeTree extends Comparable<CodeTree>{
boolean isLeaf();
Paire paire();
// need to reurn the character and ramainig bits too
CharBits getChar(List<Integer> bits);
default List<Character> decode(List<Integer> bits, List<Character> acc) {
if (bits.isEmpty()) {
return acc;
}
CharBits tmp = getChar(bits);
acc = ListModule.list(tmp.car, acc);
return decode(tmp.bits, acc);
}
List<Integer> getCode(Character car, List<Integer> acc);
List<Integer> encode(List<Character> chars, List<Integer> acc);
}