Toy project implementing a Huffman Encoder using Java 8 and Dagger 2.
I created it as an exercise in using Java 8 constructs, which you can see most prominently in the Encoder
and FrequencyDistribution
classes.
The project uses Dagger 2 to manage some very basic dependencies. All of the Dagger 2 dependencies are in maven, but if you want to run the code in eclipse (or another IDE) you'll need to set up annotation processing (as seen here, and create a target/generated-sources/annotations
source directory.
The HuffmanEncoder
class should be called to encode a message. The result of the encode()
call is a EncodingResult
object which contains both the encoded result and the encoding tree required to decode the message again.
The encoder stores the result of encoding each character in a BitSet
which is is converted into a byte array before being stored into EncodingResult
.