pub fn exhaustive_vecs_fixed_length_1_input<I: Iterator>(
xs: I,
output_types: &[BitDistributorOutputType],
) -> ExhaustiveFixedLengthVecs1Input<I> ⓘ
Expand description
Generates all length-$n$ Vec
s with elements from a single iterator.
This function differs from exhaustive_vecs_fixed_length_from_single
in that different
BitDistributorOutputType
s may be specified for each output element.
The $i$th element of output_types
is a BitDistributorOutputType
that determines how
quickly the $i$th output slot advances through the iterator; see the BitDistributor
documentation for a description of the different types. The length of the output Vec
s, $n$,
is specified by the length of output_types
.
If xs
is finite, the output length is $k^n$, where $k$ is xs.count()
and $n$ is len
. If
xs
is infinite, the output is also infinite.
If len
is 0, the output consists of one empty Vec
.
If xs
is empty, the output is also empty, unless len
is 0.
§Examples
use itertools::Itertools;
use malachite_base::chars::exhaustive::exhaustive_ascii_chars;
use malachite_base::iterators::bit_distributor::BitDistributorOutputType;
use malachite_base::vecs::exhaustive::exhaustive_vecs_fixed_length_1_input;
// We are generating length-3 [`Vec`]s of chars using one input iterator, which produces all
// ASCII chars. The third element has a tiny output type, so it will grow more slowly than the
// other two elements (though it doesn't look that way from the first few [`Vec`]s).
let xss = exhaustive_vecs_fixed_length_1_input(
exhaustive_ascii_chars(),
&[
BitDistributorOutputType::normal(1),
BitDistributorOutputType::normal(1),
BitDistributorOutputType::tiny(),
],
);
let xss_prefix = xss.take(20).collect_vec();
assert_eq!(
xss_prefix
.iter()
.map(Vec::as_slice)
.collect_vec()
.as_slice(),
&[
&['a', 'a', 'a'],
&['a', 'a', 'b'],
&['a', 'a', 'c'],
&['a', 'a', 'd'],
&['a', 'b', 'a'],
&['a', 'b', 'b'],
&['a', 'b', 'c'],
&['a', 'b', 'd'],
&['a', 'a', 'e'],
&['a', 'a', 'f'],
&['a', 'a', 'g'],
&['a', 'a', 'h'],
&['a', 'b', 'e'],
&['a', 'b', 'f'],
&['a', 'b', 'g'],
&['a', 'b', 'h'],
&['b', 'a', 'a'],
&['b', 'a', 'b'],
&['b', 'a', 'c'],
&['b', 'a', 'd']
]
);