Module malachite_base::vecs::exhaustive
source · Expand description
Iterators that generate Vec
s without repetition.
lex_vecs_length_2
use itertools::Itertools;
use malachite_base::vecs::exhaustive::lex_vecs_length_2;
let xss = lex_vecs_length_2(
['a', 'b', 'c'].iter().cloned(),
['x', 'y', 'z'].iter().cloned(),
)
.collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&['a', 'x'],
&['a', 'y'],
&['a', 'z'],
&['b', 'x'],
&['b', 'y'],
&['b', 'z'],
&['c', 'x'],
&['c', 'y'],
&['c', 'z']
]
);
lex_vecs_fixed_length_2_inputs
use itertools::Itertools;
use malachite_base::chars::exhaustive::exhaustive_ascii_chars;
use malachite_base::iterators::bit_distributor::BitDistributorOutputType;
use malachite_base::vecs::exhaustive::lex_vecs_fixed_length_2_inputs;
// We are generating length-3 `Vec`s of `char`s using two input iterators. The first iterator
// (with index 0) produces all ASCII `char`s, and the second (index 1) produces the three
// `char`s `'x'`, `'y'`, and `'z'`. The elements of `output_types` are 0, 1, and 0, meaning that
// the first element of the output `Vec`s will be taken from iterator 0, the second element from
// iterator 1, and the third also from iterator 0.
let xss = lex_vecs_fixed_length_2_inputs(
exhaustive_ascii_chars(),
['x', 'y', 'z'].iter().cloned(),
&[0, 1, 0],
);
let xss_prefix = xss.take(20).collect_vec();
assert_eq!(
xss_prefix
.iter()
.map(Vec::as_slice)
.collect_vec()
.as_slice(),
&[
&['a', 'x', 'a'],
&['a', 'x', 'b'],
&['a', 'x', 'c'],
&['a', 'x', 'd'],
&['a', 'x', 'e'],
&['a', 'x', 'f'],
&['a', 'x', 'g'],
&['a', 'x', 'h'],
&['a', 'x', 'i'],
&['a', 'x', 'j'],
&['a', 'x', 'k'],
&['a', 'x', 'l'],
&['a', 'x', 'm'],
&['a', 'x', 'n'],
&['a', 'x', 'o'],
&['a', 'x', 'p'],
&['a', 'x', 'q'],
&['a', 'x', 'r'],
&['a', 'x', 's'],
&['a', 'x', 't']
]
);
exhaustive_vecs_length_2
use itertools::Itertools;
use malachite_base::vecs::exhaustive::exhaustive_vecs_length_2;
let xss = exhaustive_vecs_length_2(
['a', 'b', 'c'].iter().cloned(),
['x', 'y', 'z'].iter().cloned(),
)
.collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&['a', 'x'],
&['a', 'y'],
&['b', 'x'],
&['b', 'y'],
&['a', 'z'],
&['b', 'z'],
&['c', 'x'],
&['c', 'y'],
&['c', 'z']
]
);
exhaustive_vecs_fixed_length_2_inputs
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_2_inputs;
// We are generating length-3 `Vec`s of `char`s using two input iterators. The first iterator
// (with index 0) produces all ASCII `char`s, and the second (index 1) produces the three
// `char`s `'x'`, `'y'`, and `'z'`. The elements of `output_types` have the indices 0, 1, and 0,
// meaning that the first element of the output `Vec`s will be taken from iterator 0, the second
// element from iterator 1, and the third also from iterator 0. 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_2_inputs(
exhaustive_ascii_chars(),
['x', 'y', 'z'].iter().cloned(),
&[
(BitDistributorOutputType::normal(1), 0),
(BitDistributorOutputType::normal(1), 1),
(BitDistributorOutputType::tiny(), 0),
],
);
let xss_prefix = xss.take(20).collect_vec();
assert_eq!(
xss_prefix
.iter()
.map(Vec::as_slice)
.collect_vec()
.as_slice(),
&[
&['a', 'x', 'a'],
&['a', 'x', 'b'],
&['a', 'x', 'c'],
&['a', 'x', 'd'],
&['a', 'y', 'a'],
&['a', 'y', 'b'],
&['a', 'y', 'c'],
&['a', 'y', 'd'],
&['a', 'x', 'e'],
&['a', 'x', 'f'],
&['a', 'x', 'g'],
&['a', 'x', 'h'],
&['a', 'y', 'e'],
&['a', 'y', 'f'],
&['a', 'y', 'g'],
&['a', 'y', 'h'],
&['b', 'x', 'a'],
&['b', 'x', 'b'],
&['b', 'x', 'c'],
&['b', 'x', 'd']
]
);
Structs
This documentation applies not only to
ExhaustiveFixedLengthVecs2Inputs
, but also to
ExhaustiveFixedLengthVecs3Inputs
, ExhaustiveFixedLengthVecs4Inputs
, and so on. See
exhaustive_vecs_fixed_length
for more information.Generates all
Vec
s with elements from a specified iterator and with lengths from another
iterator.Generates all collections of elements from an iterator, where the collections are of a fixed
length, have no repetitions, and are ordered the same way as in the iterator.
This documentation applies not only to
LexFixedLengthVecs2Inputs
, but also to
LexFixedLengthVecs3Inputs
, LexFixedLengthVecs4Inputs
, and so on. See
lex_vecs_fixed_length
for more information.Generates all collections of elements from an iterator in lexicographic order, where the
collections have no repetitions and are ordered the same way as in the iterator.
Generates all collections of elements from an iterator in lexicographic order, where the
collections have no repetitions.
Generates all collections of elements from an iterator in shortlex order, where the collections
have no repetitions and are ordered the same way as in the iterator.
Generates all
Vec
s with elements from a specified iterator and with lengths from another
iterator.Enums
Generates all
Vec
s of a given length with elements from a single iterator.Generates all collections of elements from an iterator, where the collections have no
repetitions and are ordered the same way as in the iterator.
Generates all
Vec
s of a given length with elements from a single iterator, in lexicographic
order.Functions
Generates all
Vec
s with elements from a specified iterator.Generates all length-$n$
Vec
s with elements from a single iterator.This documentation applies not only to
exhaustive_vecs_fixed_length_2_inputs
, but
also to exhaustive_vecs_fixed_length_3_inputs
,
exhaustive_vecs_fixed_length_4_inputs
, and so on. See
exhaustive_vecs_fixed_length
for more information.Generates all
Vec
s of a given length with elements from a single iterator.Generates all
Vec
s with elements from a specified iterator and with lengths from another
iterator.This documentation applies not only to
exhaustive_vecs_length_2
, but also to
exhaustive_vecs_length_3
, exhaustive_vecs_length_4
, and so on. See
exhaustive_vecs_fixed_length
for more information.Generates all
Vec
s with lengths in $[a, b]$ and with elements from a specified iterator.Generates all
Vec
s with lengths in $[a, b)$ and with elements from a specified iterator.Generates all
Vec
s with a minimum length and with elements from a specified iterator.This documentation applies not only to
lex_vecs_fixed_length_2_inputs
, but also to
lex_vecs_fixed_length_3_inputs
, lex_vecs_fixed_length_4_inputs
, and so on. See
lex_vecs_fixed_length
for more information.Generates all
Vec
s of a given length with elements from a single iterator, in lexicographic
order.This documentation applies not only to
lex_vecs_length_2
, but also to
lex_vecs_length_3
, lex_vecs_length_4
, and so on. See lex_vecs_fixed_length
for
more information.This function is used for iterating through all bit patterns with a specified number of minimum
and maximum
true
bits.Generates
Vec
s with elements from a specified iterator, in shortlex order.Generates all
Vec
s with elements from a specified iterator and with lengths from another
iterator.Generates all
Vec
s with lengths in $[a, b]$ and with elements from a specified iterator, in
shortlex order.Generates all
Vec
s with lengths in $[a, b)$ and with elements from a specified iterator, in
shortlex order.Generates all
Vec
s with a minimum length and with elements from a specified iterator, in
shortlex order.