Struct rdir_encoding::RunLength [] [src]

pub struct RunLength;

Run-length encoding.

Run-length decoding can generally be used to compress arrays that contain stretches of equal values. Instead of storing each value itself, stretches of equal values are represented by the value itself and the occurrence count, that is a value/count pair.

Examples

use rdir_encoding::RunLength;

let data = [1, 1, 1, 1, 2, 1, 1, 1, 1];
let encoded = RunLength::encode(&data).unwrap();
assert_eq!(vec![1, 4, 2, 1, 1, 4], encoded);

let decoded = RunLength::decode(&encoded).unwrap();
assert_eq!(vec![1, 1, 1, 1, 2, 1, 1, 1, 1], decoded);

Methods

impl RunLength
[src]

[src]

[src]

Encode any array of 'T' where T can be any Integer.

Trait Implementations

impl Debug for RunLength
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for RunLength

impl Sync for RunLength