An object-oriented implementation of Huffman coding in C++: build a Huffman table from text or a word-frequency table, then compress and decompress arbitrary strings against it. Part of the personal DeepAlpha trading/quant project series (used for log compression in deepalpha-logging).
Tech stack: C++17 · CMake · Boost (dynamic_bitset) · fmt
- Build a Huffman table from raw text or from a precomputed word/frequency map.
- Compress and decompress strings using the generated table.
- Serialize the Huffman table to/from a string for storage and reuse.
- Inspect table statistics (average and longest code length, predicted encoded/decoded sizes).
- Clean OOP separation:
huffman(facade) overhuffman_treeandhuffman_table.
├── main.cpp
└── huffman/
├── header/ huffman.h, huffman_table.h, huffman_tree.h
└── src/ huffman.cpp, huffman_table.cpp, huffman_tree.cpp
cmake -S . -B build # fetches fmt automatically; requires Boost installed
cmake --build build
./build/huffmanPart of the DeepAlpha series — a from-scratch, OOP take on Huffman compression using bit-level data structures.