Module exhaustive

Source
Expand description

Iterators that generate Vecs 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::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§

ExhaustiveCombinedKCompositions
Generates $k$-compositions of $n$ for all $n$ in a given range: all length-$k$ Vecs of positive usizes whose sum is in a given range.
ExhaustiveFixedLengthVecs2Inputs
This documentation applies not only to ExhaustiveFixedLengthVecs2Inputs, but also to ExhaustiveFixedLengthVecs3Inputs, ExhaustiveFixedLengthVecs4Inputs, and so on. See exhaustive_vecs_fixed_length for more information.
ExhaustiveUniqueVecs
Generates all Vecs of elements from an iterator, where the Vecs have no repetitions and are ordered the same way as in the iterator.
ExhaustiveVecs
Generates all Vecs with elements from a specified iterator and with lengths from another iterator.
LexFixedLengthOrderedUniqueCollections
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.
LexFixedLengthVecs2Inputs
This documentation applies not only to LexFixedLengthVecs2Inputs, but also to LexFixedLengthVecs3Inputs, LexFixedLengthVecs4Inputs, and so on. See lex_vecs_fixed_length for more information.
LexKCompositions
Generates all $k$-compositions of a number: all length-$k$ Vecs of positive usizes whose sum is a given number.
LexOrderedUniqueCollections
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.
LexUniqueVecs
Generates all collections of elements from an iterator in lexicographic order, where the collections have no repetitions.
LexUniqueVecsFixedLength
Generates all Vecs of elements from an iterator, where the Vecs are of a fixed length and have no repetitions.
ShortlexOrderedUniqueCollections
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.
ShortlexUniqueVecs
Generates all Vecs of elements from an iterator in shortlex order, where the Vecs have no repetitions.
ShortlexVecs
Generates all Vecs with elements from a specified iterator and with lengths from another iterator.

Enums§

ExhaustiveFixedLengthVecs1Input
Generates all Vecs of a given length with elements from a single iterator.
ExhaustiveOrderedUniqueCollections
Generates all collections of elements from an iterator, where the collections have no repetitions and are ordered the same way as in the iterator.
ExhaustiveUniqueVecsFixedLength
Generates all fixed-length Vecs of elements from an iterator, where the Vecs have no repetitions and are ordered the same way as in the iterator.
LexFixedLengthVecsFromSingle
Generates all Vecs of a given length with elements from a single iterator, in lexicographic order.

Functions§

exhaustive_combined_k_compositions
Given $n_\text{min}$, $n_\text{max}$, and $k$, generates all length-$k$ Vecs of positive usizes whose sum is in the closed interval $[n_\text{min}, n_\text{max}]$.
exhaustive_ordered_unique_vecs
Generates Vecs 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.
exhaustive_ordered_unique_vecs_fixed_length
Generates Vecs 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.
exhaustive_ordered_unique_vecs_length_inclusive_range
Generates Vecs, with lengths in a range $[a, b]$, 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.
exhaustive_ordered_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, 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.
exhaustive_ordered_unique_vecs_min_length
Generates Vecs with a mininum 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.
exhaustive_unique_vecs
Generates Vecs with elements from a single iterator, such that each Vec has no repeated elements.
exhaustive_unique_vecs_fixed_length
Generates Vecs of a given length with elements from a single iterator, such that each Vec has no repeated elements.
exhaustive_unique_vecs_length_inclusive_range
Generates Vecs, with lengths in a range $[a, b]$, with elements from a single iterator, such that each Vec has no repeated elements.
exhaustive_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, with elements from a single iterator, such that each Vec has no repeated elements.
exhaustive_unique_vecs_min_length
Generates Vecs with a mininum length, with elements from a single iterator, such that each Vec has no repeated elements.
exhaustive_vecs
Generates all Vecs with elements from a specified iterator.
exhaustive_vecs_fixed_length_1_input
Generates all length-$n$ Vecs with elements from a single iterator.
exhaustive_vecs_fixed_length_2_inputs
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.
exhaustive_vecs_fixed_length_from_single
Generates all Vecs of a given length with elements from a single iterator.
exhaustive_vecs_from_length_iterator
Generates all Vecs with elements from a specified iterator and with lengths from another iterator.
exhaustive_vecs_length_2
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.
exhaustive_vecs_length_inclusive_range
Generates all Vecs with lengths in $[a, b]$ and with elements from a specified iterator.
exhaustive_vecs_length_range
Generates all Vecs with lengths in $[a, b)$ and with elements from a specified iterator.
exhaustive_vecs_min_length
Generates all Vecs with a minimum length and with elements from a specified iterator.
lex_k_compositions
Generates all $k$-compositions of a number: given $n$ and $k$, generates all length-$k$ Vecs of positive usizes whose sum is $n$.
lex_ordered_unique_vecs
Generates Vecs 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.
lex_ordered_unique_vecs_fixed_length
Generates Vecs 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.
lex_ordered_unique_vecs_length_inclusive_range
Generates Vecs, with lengths in a range $[a, b]$, 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.
lex_ordered_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, 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.
lex_ordered_unique_vecs_min_length
Generates Vecs with a mininum 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.
lex_unique_vecs
Generates Vecs with elements from a single iterator, such that each Vec has no repeated elements.
lex_unique_vecs_fixed_length
Generates Vecs of a given length with elements from a single iterator, such that each Vec has no repeated elements.
lex_unique_vecs_length_inclusive_range
Generates Vecs with a mininum length, with elements from a single iterator, such that each Vec has no repeated elements.
lex_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, with elements from a single iterator, such that each Vec has no repeated elements.
lex_unique_vecs_min_length
Generates Vecs with a mininum length, with elements from a single iterator, such that each Vec has no repeated elements.
lex_vecs_fixed_length_2_inputs
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.
lex_vecs_fixed_length_from_single
Generates all Vecs of a given length with elements from a single iterator, in lexicographic order.
lex_vecs_length_2
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.
next_bit_pattern
This function is used for iterating through all bit patterns with a specified number of minimum and maximum true bits.
shortlex_ordered_unique_vecs
Generates Vecs 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.
shortlex_ordered_unique_vecs_length_inclusive_range
Generates Vecs, with lengths in a range $[a, b]$, 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.
shortlex_ordered_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, 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.
shortlex_ordered_unique_vecs_min_length
Generates Vecs with a mininum 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.
shortlex_unique_vecs
Generates Vecs with elements from a single iterator, such that each Vec has no repeated elements.
shortlex_unique_vecs_length_inclusive_range
Generates Vecs, with lengths in a range $[a, b]$, with elements from a single iterator, such that each Vec has no repeated elements.
shortlex_unique_vecs_length_range
Generates Vecs, with lengths in a range $[a, b)$, with elements from a single iterator, such that each Vec has no repeated elements.
shortlex_unique_vecs_min_length
Generates Vecs with a mininum length, with elements from a single iterator, such that each Vec has no repeated elements.
shortlex_vecs
Generates Vecs with elements from a specified iterator, in shortlex order.
shortlex_vecs_from_length_iterator
Generates all Vecs with elements from a specified iterator and with lengths from another iterator.
shortlex_vecs_length_inclusive_range
Generates all Vecs with lengths in $[a, b]$ and with elements from a specified iterator, in shortlex order.
shortlex_vecs_length_range
Generates all Vecs with lengths in $[a, b)$ and with elements from a specified iterator, in shortlex order.
shortlex_vecs_min_length
Generates all Vecs with a minimum length and with elements from a specified iterator, in shortlex order.