Function malachite_base::num::random::striped::get_striped_unsigned_vec
source · [−]pub fn get_striped_unsigned_vec<T: PrimitiveUnsigned>(
bit_source: &mut StripedBitSource,
bit_len: u64
) -> Vec<T>
Expand description
Generates a striped unsigned Vec
, with a given number of bits (not length!), from a
StripedBitSource
.
See here for more information.
The output length is bit_len.div_round(T::WIDTH, RoundingMode::Ceiling)
.
Expected complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is bit_len
.
Examples
extern crate itertools;
use itertools::Itertools;
use malachite_base::num::random::striped::{get_striped_unsigned_vec, StripedBitSource};
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::ToBinaryString;
let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);
let xs = get_striped_unsigned_vec::<u8>(&mut bit_source, 100)
.iter()
.map(u8::to_binary_string)
.collect_vec();
assert_eq!(
xs,
&[
"11111000", "111111", "11100000", "11111111", "111", "11000000", "11111111", "0", "0",
"11111000", "11111111", "11111111", "11",
]
);