pub struct RecursiveIndexing;
Expand description
Recursive indexing encoding Recursive indexing encodes values such that the encoded values lie within the open interval (MIN, MAX). This allows to create a more compact representation of a 32-bit signed integer array when the majority of values in the array fit into 16-bit (or 8-bit). To encode each value in the input array the method stores the value itself if it lies within the open interval (MIN, MAX), otherwise the MAX (or MIN if the number is negative) interval endpoint is stored and subtracted from the input value. This process of storing and subtracting is repeated recursively until the remainder lies within the interval.
Note that MAX
and MIN
are the largest and smallest value that can be
represented by the i16
integer type
§Examples
use rdir_encoding::RecursiveIndexing;
let data = [1, 420, 32767, 120, -32768, 32769];
let encoded = RecursiveIndexing::encode(&data).unwrap();
assert_eq!(encoded, vec![1, 420, 32767, 0, 120, -32768, 0, 32767, 2]);
let decoded = RecursiveIndexing::decode(&encoded).unwrap();
assert_eq!(decoded, data);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RecursiveIndexing
impl RefUnwindSafe for RecursiveIndexing
impl Send for RecursiveIndexing
impl Sync for RecursiveIndexing
impl Unpin for RecursiveIndexing
impl UnwindSafe for RecursiveIndexing
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