Module builder

Source
Expand description

§AtomicFixedVec Builder

This module provides a builder for constructing an owned AtomicFixedVec from a slice of data (&[T]). It mirrors the functionality of the standard FixedVecBuilder, allowing for automatic bit-width detection and a consistent API.

§Examples

§Building from a slice

use compressed_intvec::prelude::*;
use compressed_intvec::fixed::{AtomicFixedVec, UAtomicFixedVec, BitWidth};

let data: &[u32] = &[10, 20, 30, 40, 50];

// The builder can infer the minimal bit width (6 bits for 50).
let vec: UAtomicFixedVec<u32> = AtomicFixedVec::builder()
    .build(data)
    .unwrap();

assert_eq!(vec.bit_width(), 6);

// Or a specific strategy can be chosen.
let vec_pow2: UAtomicFixedVec<u32> = AtomicFixedVec::builder()
    .bit_width(BitWidth::PowerOfTwo)
    .build(data)
    .unwrap();

assert_eq!(vec_pow2.bit_width(), 8);

Structs§

AtomicFixedVecBuilder
A builder for creating an AtomicFixedVec from a slice of integers.