Skip to main content

int_vec

Macro int_vec 

Source
macro_rules! int_vec {
    () => { ... };
    ($($elem:expr),* $(,)?) => { ... };
    ($elem:expr; $len:expr) => { ... };
}
Expand description

Creates a LEVarVec (a VarVec of u64s) containing the given elements.

int_vec! allows for concise initialization of a LEVarVec, which is an alias for VarVec<u64, LE>. It uses a set of reasonable defaults for its build parameters:

  • Codec: Codec::Auto is used to automatically select the most space-efficient codec for the provided data.
  • Sampling Rate (k): A default value of 16 is used, offering a good balance between random access speed and memory overhead.

§Note on Types

The macro infers the element type from the input. For explicit control over parameters, use VarVec::builder.

§Examples

Create an empty LEVarVec:

let v: LEVarVec = int_vec![];
assert!(v.is_empty());

Create a crate::variable::VarVec from a list of elements:

  let v = int_vec![100u32, 200, 300, 1024];
assert_eq!(v.len(), 4);
assert_eq!(v.get(1), Some(200));

Create a crate::variable::VarVec with a repeated element:

  let v = int_vec![42u8; 100];
assert_eq!(v.len(), 100);
assert_eq!(v.get(50), Some(42));