Macro int_vec

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

Creates a LEIntVec (an IntVec of u64s) containing the given elements.

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

  • Codec: VariableCodecSpec::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

All input elements are automatically cast to u64. To avoid ambiguity, it is good practice to use a type suffix on at least the first literal (e.g., 100u64).

For more control over these parameters, or to use a different integer type, please use the IntVec::builder.

§Examples

Create an empty LEIntVec:

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

Create an LEIntVec from a list of elements:

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

Create an LEIntVec with a repeated element:

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