Struct rdir_encoding::Delta
[−]
[src]
pub struct Delta;
Delta encoding.
Delta encoding is used to store an array of numbers. Instead of storing the numbers themselves, the differences (deltas) between the numbers are stored. When the values of the deltas are smaller than the numbers themselves they can be more efficiently packed to require less space.
Note that arrays in which the values change by an identical amount for a range of consecutive values lend themselves to subsequent run-length encoding.
Examples
use rdir_encoding::Delta; let encoded = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 5]; let expected = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 20]; let decoded = Delta::decode(&encoded).unwrap(); assert_eq!(expected, decoded);
Methods
impl Delta
[src]
pub fn decode(values: &[i32]) -> Result<Vec<i32>, RdirError>
[src]
Decode given values
pub fn encode<T>(values: &[T]) -> Result<Vec<i32>, RdirError> where
T: Integer + NumCast + PrimInt,
[src]
T: Integer + NumCast + PrimInt,
Encode any array of 'T' where T
can be any Integer.