Module mayda::monotone [] [src]

Monotone encoding of integer arrays. Intended for cases where the entries are monotonically increasing. Implemented for all primitive integer types.

This type is specifically intended for arrays with monotone increasing entries. A blocks of entries is transformed into an offset and an array of differences of successive entries, and the array of differences is encoded. Compression decays with the maximum magnitude of the difference of successive entries.

Examples

use mayda::{Access, Encode, Monotone};

let input: Vec<u32> = vec![1, 5, 7, 15, 20, 27];
let mut bits = Monotone::new();
bits.encode(&input).unwrap();

let length = bits.len();
assert_eq!(length, 6);

let output = bits.decode();
assert_eq!(input, output);

let value = bits.access(4);
assert_eq!(value, 20);

let range = bits.access(1..4);
assert_eq!(range, vec![5, 7, 15]); 

Structs

Monotone

The type of a monotone encoded integer array. Designed for moderate compression and efficient decoding through the Encode trait, and efficient random access through the Access and AccessInto traits.