pub struct RunLength;Expand description
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);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RunLength
impl RefUnwindSafe for RunLength
impl Send for RunLength
impl Sync for RunLength
impl Unpin for RunLength
impl UnwindSafe for RunLength
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more