bit-long-vec 0.2.1

Vector with fixed bit sized values stored in long.
Documentation
  • Coverage
  • 90.91%
    10 out of 11 items documented1 out of 7 items with examples
  • Size
  • Source code size: 13.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.45 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • eihwaz/bit-long-vec
    1 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vagola

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);
}