Crate rle_vec [] [src]

This crate provides RleVec, a vector like structure that stores runs of identical values coded by the value and the number of repeats.

If your data consists of long stretches of identical values is can be beneficial to only store the number of times each value occurs. This can result in significant space savings, but there is a cost. Accessing an arbitrary index requires a binary search over the stored runs resulting in a O(log n) complexity versus O(1) for a normal vector. Other complexities are in the table where n is equal to the number of runs, not the length of a comparable Vec.

push index set with breaking a run set without breaking a run insert with breaking a run insert without breaking a run
RleVec O(1) O(log n) O((log n) + 2n) O(log n) O((log n) + 2n) O((log n) + n)
Vec O(1) O(1) O(1)* O(n)

*Benchmarks show that setting vec[idx] = value is a lot slower than getting vec[idx]

Structs

RleVec
RleVecIterator