Function malachite_base::vecs::random::random_unique_vecs_fixed_length
source · pub fn random_unique_vecs_fixed_length<I: Iterator>(
len: u64,
xs: I
) -> RandomUniqueVecsFixedLength<I> ⓘwhere
I::Item: Eq + Hash,
Expand description
Randomly generates Vec
s of a given length, where the Vec
s have no repeated elements.
The input iterator must generate at least len
distinct elements; otherwise, this iterator
will hang.
If len
is 0, the output consists of the empty list, repeated.
xs
must be infinite.
Examples
use itertools::Itertools;
use malachite_base::num::random::random_unsigned_inclusive_range;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::vecs::random::random_unique_vecs_fixed_length;
let xss = random_unique_vecs_fixed_length(
2,
random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),
)
.take(10)
.collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[95, 24],
&[99, 71],
&[93, 53],
&[85, 34],
&[48, 2],
&[55, 11],
&[48, 18],
&[90, 93],
&[67, 93],
&[93, 95]
]
);