pub fn exhaustive_unique_pairs<I: Iterator>(xs: I) -> ExhaustiveUniquePairs<I> 
where I::Item: Clone,
Expand description

Generates pairs of elements from a single iterator, such that each pair 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 $\tfrac{1}{2}{n!}$.

If xs is empty, the output is also empty.

§Examples

use itertools::Itertools;
use malachite_base::tuples::exhaustive::exhaustive_unique_pairs;

let xss = exhaustive_unique_pairs(1..=6).take(20).collect_vec();
assert_eq!(
    xss.into_iter().collect_vec().as_slice(),
    &[
        (1, 2),
        (2, 1),
        (1, 3),
        (3, 1),
        (2, 3),
        (3, 2),
        (1, 4),
        (4, 1),
        (2, 4),
        (4, 2),
        (3, 4),
        (4, 3),
        (1, 5),
        (5, 1),
        (2, 5),
        (5, 2),
        (3, 5),
        (5, 3),
        (4, 5),
        (5, 4)
    ]
);