bit-long-vec

Crates.iobit-long-vec
lib.rsbit-long-vec
version0.2.1
sourcesrc
created_at2019-09-29 21:41:53.72391
updated_at2019-10-02 20:32:49.340578
descriptionVector with fixed bit sized values stored in long.
homepagehttps://github.com/eihwaz/bit-long-vec
repositoryhttps://github.com/eihwaz/bit-long-vec
max_upload_size
id168689
size13,939
(vagola)

documentation

README

bit-long-vec

crates.io Build Status codecov

Vector with fixed bit sized values stored in long. Effective to reduce the amount of memory needed for storage values whose size is not a power of 2. As drawback to set and get values uses additional CPU cycles for bit operations.

Usage

Add this to your Cargo.toml:

[dependencies]
bit-long-vec = "0.2"

Example

In this particular scenario, we want to store 10 bit values. It takes 200 bytes to store 100 values using short. To store 100 values using a bit long vector, 15 lengths are required, which is 120 bytes. (-40%).

let mut vec = BitLongVec::with_fixed_capacity(100, 10);

for index in 0..100 {
    vec.set(index, 1023);

    assert_eq!(vec.get(index), 1023);
}
Commit count: 28

cargo fmt