Crates.io | delta-encoding |
lib.rs | delta-encoding |
version | |
source | src |
created_at | 2022-06-30 01:41:34.474208 |
updated_at | 2024-12-26 21:04:26.477427 |
description | A library to encode and decode a delta-encoded stream of numbers |
homepage | |
repository | https://github.com/nyurik/delta-encoding |
max_upload_size | |
id | 616107 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A simple library for encoding and decoding a stream of values as delta-encoded. For example, if you have a stream of values like this:
1, 3, 2, 4, 5
the delta-encoded stream would be:
1, 2, -1, 2, 1
use delta_encoding::{DeltaEncoderExt, DeltaDecoderExt};
pub fn main() {
let data = vec![1, 2, 5, 4, 2];
// Delta-encode without consuming, and without making a vector copy
let encoded: Vec<i64> = data.iter().copied().deltas().collect();
assert_eq!(encoded, vec![1, 1, 3, -1, -2]);
// Consume and delta-encode
let encoded: Vec<i64> = data.into_iter().deltas().collect();
assert_eq!(encoded, vec![1, 1, 3, -1, -2]);
let data = vec![1, 1, 3, -1, -2];
// Delta-decode without consuming, and without making a vector copy
let decoded: Vec<i64> = data.iter().copied().original().collect();
assert_eq!(decoded, vec![1, 2, 5, 4, 2]);
// Consume and delta-decode
let decoded: Vec<i64> = data.into_iter().original().collect();
assert_eq!(decoded, vec![1, 2, 5, 4, 2]);
}
make
.
Install it with cargo install just
.just
.just test
.Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.