huffman-compress
Huffman compression given a probability distribution over arbitrary symbols.
Examples
extern crate bit_vec;
extern crate huffman_compress;
use HashMap;
use BitVec;
use ;
let mut weights = new;
weights.insert;
weights.insert;
weights.insert;
weights.insert;
weights.insert;
// Construct a Huffman code based on the weights (e.g. counts or relative
// frequencies).
let = codebook;
// More frequent symbols will be encoded with fewer bits.
assert!;
// Encode some symbols using the book.
let mut buffer = new;
let example = vec!;
for symbol in &example
// Decode the symbols using the tree.
let decoded: = tree.decoder.collect;
assert_eq!;
Documentation
Changelog
- 0.1.0
- Initial release.
License
huffman-compress is dual licensed under the Apache 2.0 and MIT license, at your option.