pub fn exhaustive_ordered_unique_vecs_fixed_length<I: Iterator>(
k: u64,
xs: I,
) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>> ⓘ
Expand description
Generates Vec
s of a given length with elements from a single iterator, such that each
Vec
has no repeated elements, and the elements in each Vec
are ordered the same way as
they are in the source iterator.
The source iterator should not repeat any elements, but this is not enforced.
If $k$ is 0, the output length is 1.
If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.
If $k$ is nonzero and the input iterator length is $n$, the output length is $\binom{n}{k}$.
If $k$ is 0, the output consists of one empty Vec
.
If xs
is empty, the output is also empty, unless $k$ is 0.
§Examples
use itertools::Itertools;
use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_fixed_length;
let xss = exhaustive_ordered_unique_vecs_fixed_length(4, 1..=6).collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[1, 2, 3, 4],
&[1, 2, 3, 5],
&[1, 2, 4, 5],
&[1, 3, 4, 5],
&[2, 3, 4, 5],
&[1, 2, 3, 6],
&[1, 2, 4, 6],
&[1, 3, 4, 6],
&[2, 3, 4, 6],
&[1, 2, 5, 6],
&[1, 3, 5, 6],
&[2, 3, 5, 6],
&[1, 4, 5, 6],
&[2, 4, 5, 6],
&[3, 4, 5, 6]
]
);