Expand description
§FixedVec
Builders
This module provides builders for constructing an owned FixedVec
.
There are two main builders:
FixedVecBuilder
: For building from a slice (&[T]
). It can automatically determine the optimal bit width from the data.FixedVecFromIterBuilder
: For building from an iterator. This is useful for large datasets, but requires the bit width to be specified manually.
§Examples
§Building from a slice
use compressed_intvec::fixed::{FixedVec, BitWidth, UFixedVec};
use compressed_intvec::fixed::builder::FixedVecBuilder;
let data: &[u32] = &[10, 20, 30, 40, 50];
// The builder can infer the minimal bit width.
let vec: UFixedVec<u32> = FixedVecBuilder::new()
.build(data)
.unwrap();
assert_eq!(vec.bit_width(), 6); // 50 requires 6 bits
// Or a specific strategy can be chosen.
let vec_pow2: UFixedVec<u32> = FixedVecBuilder::new()
.bit_width(BitWidth::PowerOfTwo)
.build(data)
.unwrap();
assert_eq!(vec_pow2.bit_width(), 8);
Structs§
- Fixed
VecBuilder - A builder for creating a
FixedVec
from a slice of integers. - Fixed
VecFrom Iter Builder - A builder for creating a
FixedVec
from an iterator.