pub fn exhaustive_unique_vecs<I: Iterator>(xs: I) -> ExhaustiveUniqueVecs<I>Notable traits for ExhaustiveUniqueVecs<I>impl<I: Iterator> Iterator for ExhaustiveUniqueVecs<I> where
    I::Item: Clone
type Item = Vec<I::Item>;
where
    I::Item: Clone
Expand description

Generates Vecs with elements from a single iterator, such that each Vec has no repeated elements.

The source iterator should not repeat any elements, but this is not enforced.

If the input iterator is infinite, the output length is also infinite.

If the input iterator length is $n$, the output length is $$ \sum_ {k=0}^n \frac{n!}{k!} $$ $$ = \begin{cases} 1 & \text{if} \quad n = 0, \\ 2 & \text{if} \quad n = 1, \\ \operatorname{round}(en!) & \text{otherwise}. \end{cases} $$

See https://oeis.org/A000522.

If xs is empty, the output consists of a single empty Vec.

Examples

extern crate itertools;

use itertools::Itertools;
use malachite_base::vecs::exhaustive::exhaustive_unique_vecs;

let xss = exhaustive_unique_vecs(1..=4).take(20).collect_vec();
assert_eq!(
    xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[][..],
        &[1],
        &[2],
        &[3],
        &[1, 2],
        &[1, 3],
        &[2, 1],
        &[1, 2, 3],
        &[3, 1],
        &[2, 3],
        &[3, 2],
        &[4],
        &[1, 3, 2],
        &[1, 4],
        &[2, 1, 3],
        &[3, 4],
        &[2, 3, 1],
        &[4, 1],
        &[3, 1, 2],
        &[2, 4]
    ]
);