Skip to main content

Module bitenc

Module bitenc 

Source
Expand description

A fixed-width bit encoding implementation. This allows to store a sequence of values over a reduced alphabet by packing them bit-encoded into a sequence of bytes.

Similar behaviour can be achieved using a PackedVec from the packedvec crate.

§Example

use fqtk_lib::bitenc::BitEnc;
let mut bitenc = BitEnc::new(2);
bitenc.push(0);
bitenc.push(2);
bitenc.push(1);
let values: Vec<u8> = bitenc.iter().collect();
assert_eq!(values, [0, 2, 1]);

Structs§

BitEnc
A sequence of bitencoded values.
BitEncIter
Iterator over values of a bitencoded sequence (values will be unpacked into bytes). Used to implement the iter method of BitEnc.