Skip to main content

Module mtf

Module mtf 

Source
Expand description

MTF (Move To Front) encoder/decoder Produces a rank for each input character based on when it was seen last time. Useful for BWT output encoding, which produces a lot of zeroes and low ranks.

http://en.wikipedia.org/wiki/Move-to-front_transform

§Example

use std::io::{self, Read, Write};
use compress::bwt::mtf;

// Encode a stream of bytes
let bytes = b"abracadabra";
let mut e = mtf::Encoder::new(io::BufWriter::new(Vec::new()));
e.write_all(bytes).unwrap();
let encoded = e.finish().into_inner().unwrap();

// Decode a stream of ranks
let mut d = mtf::Decoder::new(io::BufReader::new(&encoded[..]));
let mut decoded = Vec::new();
let result = d.read_to_end(&mut decoded).unwrap();

§Credit

Structs§

Decoder
A simple MTF stream decoder
Encoder
A simple MTF stream encoder
MTF
MoveToFront encoder/decoder

Constants§

TOTAL_SYMBOLS

Type Aliases§

Rank
Symbol